Skip to content
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: Skip over contents of RAWTEXT elements such as STYLE. #5145

Conversation

dmsnell
Copy link
Member

@dmsnell dmsnell commented Sep 6, 2023

Trac Ticket: #59292

When encountering elements that imply switching into the RAWTEXT parsing state, the Tag Processor should skip processing until existing the RAWTEXT state.

In this patch the Tag Processor does just that, except for the case of the deprecated XMP element which implies further and more complicated rules.

There's an implicit assumption that the SCRIPT ENABLED flag in HTML parsing is enabled so that the contents of NOSCRIPT can be skipped. Otherwise, it would be required to parse the contents of that tag.

This was not a reported bug; it was discovered through the Core unit test cases for kses

/**
* Skips contents of generic rawtext elements.
*
* @since {VERSION NUMBER}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @since {VERSION NUMBER}
* @since 6.4.0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you'd like it also in 6.3.x, as it qualifies as a bugfix? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's definitely a bug-fix, though it looks like I overlooked creating it that way in Trac. if we can get it into 6.3 I would prefer that. the error case is that if someone parses HTML with things that look like HTML tags inside of a STYLE element or the other RAWTEXT elements in this patch, then the HTML API will think they are real tags.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Judging from chatter in the #6-3-release-leads channel, it looks as if there's plans for a 6.3.2. I'll set that as the milestone for the ticket then and will backport the changeset to the 6.3 branch 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. I'll make sure to apply this one to the 6.3 compat folder in Gutenberg as well then

Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question and one minor nit, but otherwise looking good 👍

@dmsnell dmsnell force-pushed the html-api/fix-skip-contents-of-rawtext-elements branch from f60bab5 to 2e0264f Compare September 12, 2023 23:59
When encountering elements that imply switching into the RAWTEXT parsing state,
the Tag Processor should skip processing until existing the RAWTEXT state.

In this patch the Tag Processor does just that, except for the case of the
deprecated XMP element which implies further and more complicated rules.

There's an implicit assumption that the SCRIPT ENABLED flag in HTML parsing
is enabled so that the contents of NOSCRIPT can be skipped. Otherwise, it would
be required to parse the contents of that tag.
@dmsnell dmsnell force-pushed the html-api/fix-skip-contents-of-rawtext-elements branch from 2e0264f to a6159d8 Compare September 13, 2023 00:07
@ockham
Copy link
Contributor

ockham commented Sep 13, 2023

Committed to Core trunk in https://core.trac.wordpress.org/changeset/56563.

@ockham ockham closed this Sep 13, 2023
@ockham
Copy link
Contributor

ockham commented Sep 13, 2023

Backported to Core's 6.3 branch in https://core.trac.wordpress.org/changeset/56564.

@dmsnell dmsnell deleted the html-api/fix-skip-contents-of-rawtext-elements branch September 13, 2023 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants