Go Vulnerability Database
GO-2026-6860
Avoid quadratic complexity when coalescing text nodes in html in golang.org/x/net
Details
When coalescing adjacent text nodes in addText and fosterParent, appending to an existing TextNode's Data via string concatenation (n.Data += text) reallocated and copied the accumulated string on every token. Inputs containing many short text runs separated by ignored end tags (such as "a</x>") caused O(n^2) allocations and byte copies.
Accumulate coalesced text in per-node byte slices during parsing and materialize Data strings once at the end of parse.
Affected packages
| Ecosystem | Package | Affected versions |
|---|---|---|
| Go | golang.org/x/net | All versions before 0.62.0 (fixed in 0.62.0) |