-
Notifications
You must be signed in to change notification settings - Fork 3.2k
HTML API: Test and fix svg script handling #7164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTML API: Test and fix svg script handling #7164
Conversation
The spec seems to have been misinterpreted, although the result was ultimately the same. > If the token has its self-closing flag set, then run the appropriate steps from the following list: > > If the token's tag name is "script", and the new current node is in the SVG namespace > Acknowledge the token's self-closing flag, and then act as described in the steps for a "script" end tag below. > … > An end tag whose tag name is "script", if the current node is an SVG script element
|
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. |
| if ( $this->is_tag_closer() && 'SCRIPT' === $this->state->current_token->node_name && 'svg' === $this->state->current_token->namespace ) { | ||
| in_foreign_content_svg_script_close_tag: | ||
| $this->state->stack_of_open_elements->pop(); | ||
| return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a fall-through to the next conditional block that I believe was unintentional. Typically, we expect to enter a single block.
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. |
dmsnell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic seems sound. Also, I think a thing I couldn't make sense of, and is now obvious, is that if we have a self-closing tag, then the current node must needs be a SCRIPT tag in the SVG namespace, because no other nodes can be added to the stack of open elements before closing the self-closer.
When support was added for foreign content, an ambiguity in the HTML specification led to code that followed the wrong path when encountering a self-closing SCRIPT element in the SVG namespace. Further, a fallthrough was discovered during manual testing. This patch adds a new test to assert the proper behaviors and fixes these issues. In the case of the SCRIPT element, the outcome was the same with the wrong code path, making the defect benign. In the case of the fallthrough, the wrong behavior would occur. The updates in this patch also resolves a todo relating to the spec ambiguity. Developed in #7164 Discussed in https://core.trac.wordpress.org/ticket/61576 Follow-up to [58868]. Props: dmsnell, jonsurrell. See #61576. git-svn-id: https://develop.svn.wordpress.org/trunk@58871 602fd350-edb4-49c9-b593-d223f7449a82
When support was added for foreign content, an ambiguity in the HTML specification led to code that followed the wrong path when encountering a self-closing SCRIPT element in the SVG namespace. Further, a fallthrough was discovered during manual testing. This patch adds a new test to assert the proper behaviors and fixes these issues. In the case of the SCRIPT element, the outcome was the same with the wrong code path, making the defect benign. In the case of the fallthrough, the wrong behavior would occur. The updates in this patch also resolves a todo relating to the spec ambiguity. Developed in WordPress/wordpress-develop#7164 Discussed in https://core.trac.wordpress.org/ticket/61576 Follow-up to [58868]. Props: dmsnell, jonsurrell. See #61576. Built from https://develop.svn.wordpress.org/trunk@58871 git-svn-id: http://core.svn.wordpress.org/trunk@58267 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When support was added for foreign content, an ambiguity in the HTML specification led to code that followed the wrong path when encountering a self-closing SCRIPT element in the SVG namespace. Further, a fallthrough was discovered during manual testing. This patch adds a new test to assert the proper behaviors and fixes these issues. In the case of the SCRIPT element, the outcome was the same with the wrong code path, making the defect benign. In the case of the fallthrough, the wrong behavior would occur. The updates in this patch also resolves a todo relating to the spec ambiguity. Developed in WordPress/wordpress-develop#7164 Discussed in https://core.trac.wordpress.org/ticket/61576 Follow-up to [58868]. Props: dmsnell, jonsurrell. See #61576. Built from https://develop.svn.wordpress.org/trunk@58871 git-svn-id: https://core.svn.wordpress.org/trunk@58267 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When support was added for foreign content, an ambiguity in the HTML specification led to code that followed the wrong path when encountering a self-closing SCRIPT element in the SVG namespace. Further, a fallthrough was discovered during manual testing. This patch adds a new test to assert the proper behaviors and fixes these issues. In the case of the SCRIPT element, the outcome was the same with the wrong code path, making the defect benign. In the case of the fallthrough, the wrong behavior would occur. The updates in this patch also resolves a todo relating to the spec ambiguity. Developed in WordPress#7164 Discussed in https://core.trac.wordpress.org/ticket/61576 Follow-up to [58868]. Props: dmsnell, jonsurrell. See #61576. git-svn-id: https://develop.svn.wordpress.org/trunk@58871 602fd350-edb4-49c9-b593-d223f7449a82
Trac ticket: https://core.trac.wordpress.org/ticket/61576
Follow-up to: [58868] (GitHub #6006).
The spec states the following:
I believe the original implementation was incorrect and the intention is to move into the An end tag whose tag name is "script", if the current node is an SVG script element instructions and not the Any other end tag. Ultimately, the result was the same.
This also adds a missing
return truefrom the script end tag block.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.