-
Notifications
You must be signed in to change notification settings - Fork 3.2k
HTML API: Align STYLE tag contents escaping with SCRIPT tag #10668
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
base: trunk
Are you sure you want to change the base?
HTML API: Align STYLE tag contents escaping with SCRIPT tag #10668
Conversation
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. |
6ff95c3 to
9f2f45b
Compare
| /* | ||
| * Replace all instances of the ASCII case-insensitive match of "</style" | ||
| * when followed by whitespace or "/" or ">", by using a CSS Unicode | ||
| * escape sequence for the "s" (or the "S"). | ||
| * | ||
| * CSS Unicode escape sequences will terminate at the first non-hexadecimal, | ||
| * so the `t` character in `style` ensures that a Unicode escape sequence | ||
| * like `\73t` is correctly interpreted as `st`. | ||
| */ | ||
| while ( $at < $end ) { | ||
| $tag_at = stripos( $text, '</style', $at ); | ||
| if ( false === $tag_at ) { | ||
| break; | ||
| } | ||
|
|
||
| if ( 1 !== strspn( $text, " \t\f\r\n/>", $tag_at + 7, 1 ) ) { | ||
| $at = $tag_at + 7; | ||
| continue; | ||
| } | ||
|
|
||
| $escaped .= substr( $text, $was_at, $tag_at - $was_at + 2 ); | ||
| $escaped .= 's' === $text[ $tag_at + 2 ] ? '\73' : '\53'; | ||
| $was_at = $tag_at + 3; | ||
| $at = $tag_at + 8; | ||
| } |
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.
Would there be an opportunity to factor this out into a common method to be reused by both escape_style_contents and escape_javascript_script_contents?
#10635 is merged here. It should land first so that this approach can align with what finally lands there.
Trac ticket:
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.