Repository navigation
🐛 fix(dom): keep text order after the depth cap lifts - #2545
Merged
Merged
Conversation
An append the 512-level cap refuses goes after its parent instead. When the adoption agency later moves that parent back under the cap, the next append went into it, ahead of the nodes already placed after it. A parent the cap refused now keeps refusing.
Merging this PR will not alter performance
Comparing Footnotes
|
Copying an option into a selectedcontent removes the selectedcontent's children, which can detach an element the cap refused while it is still open. The next append into it followed the refused element's parent, now NULL, and crashed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The scheduled fuzzer's encoding target compares a byte parse against a parse of the decoded text and against html5lib. Three of its findings on main come from two causes, one in the parser and one in the oracle.
Parser: text order after the depth cap lifts. The DOM stops at 512 levels. An append the cap refuses goes after its parent instead, and the docs promise that text keeps its source order. The adoption agency can then move that parent back under the cap: eight blocks under an
<a>run its outer loop to its end, and the last one lifts the paragraph inside them. The next append went into the paragraph, ahead of the text the cap had already placed after it:A parent the cap refused now keeps refusing, so later content lands after the earlier run. The check costs nothing until a parse first gets near the cap.
Oracle: html5lib's in-body "any other end tag" ignores namespaces. WHATWG matches only an HTML element of the token's name and stops at the first special element. html5lib compares bare names, so in
<math><mi><x></mi>it pops back to<math>, where turbohtml correctly stops at the special MathMLmi. A NUL after that point is foreign content to html5lib (U+FFFD) and in-body content to turbohtml (dropped). The reference wrapper now patches the handler, as it already does for the adoption agency and several other html5lib gaps.