HTML API: Ensure that HTML nodes in foreign content are handled#7347
HTML API: Ensure that HTML nodes in foreign content are handled#7347sirreal wants to merge 3 commits intoWordPress:trunkfrom
Conversation
This condition: > Reprocess the token according to the rules given in the section > corresponding to the current insertion mode in HTML content. Was resulting in an infinite loop in fragment cases. In full documents, after popping nodes the context is always moved so that foreign content parsing is not used. This is not guaranteed in a fragment and could cause an infinite loop.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
In the rules for parsing tokens in foreign content there are 2 places that indicated tokens should be processed "according to the rules given in the section corresponding to the current insertion mode in HTML content."
First (bold mine):
And later (bold mine):
While working on fragment parsing and html5lib-tests in dmsnell#22, I discovered an infinite loop that seems to occur in the following situation. At an
svg:svgcontext node, create a fragment parser for with HTML</p>. This is the first condition mentioned.In a full parser, the instruction "While the current node is not a MathML text integration point, an HTML integration point, or an element in the HTML namespace, pop elements from the stack of open elements." would ensure that when reprocessing the token it does not re-enter the foreign content rules because by popping elements the token would no longer be foreign content. However, in a fragment parser there may not be any nodes to pop and the context element may continue to cause foreign content handling to be applied, triggering an infinite loop. The instruction in the specification seems to indicate that the token should be handled in the current HTML insertion mode. This is fixed by moving to the same place in both cases which is a reproduction of the HTML handling switch on the current insertion mode.
This fixes the infinite loop that that appeared in dmsnell#22.
Observed in dmsnell#22.
Follow-up to [58868]
See: #61576
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.