-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Custom CSS: Relax CSS validation rules #10641
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
Draft
sirreal
wants to merge
16
commits into
WordPress:trunk
Choose a base branch
from
sirreal:64418/improve-custom-css-handling
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7c01020
Relax style tag contents validation
sirreal 511284e
Apply suggestions from code review
sirreal edca2a2
Update comments and document in since annotation
sirreal db273b7
Update customizer error message
sirreal 62d59c2
Update wp_custom_css_cb to rely on HTML API for safe SCRIPT tag print…
sirreal f3a1716
Wrap customizer CSS test in newlines
sirreal e793caa
Use HTML API for style tags in script-loader
sirreal aa7852c
Use HTML Tag Processor to produce WP_Styles style tags
sirreal 93cddc3
Use HTML Tag Processor for STYLE tags in theme.php
sirreal 41a1fe3
PICKME: Update styles tests to use assertEqualHTML
sirreal 99b8733
Simplify conditional style no-print test
sirreal 2ea6a12
Correctly check presence with stripos
sirreal 81679af
Merge branch 'trunk' into 64418/improve-custom-css-handling
sirreal e3a6d78
Merge branch 'trunk' into 64418/improve-custom-css-handling
sirreal 2c19861
Update failing test, add test for allowed CSS
sirreal 05a45e1
Merge branch 'trunk' into 64418/improve-custom-css-handling
sirreal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.
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.
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.
it might be worth calling
next_token()here to verify that there are no further tokens, as we expect none. if we get one, it means that something inside of$this->type_attrbroke out of the tag and potentially out of the style.in fact, if we do this before setting the modifiable text we can ensure those attributes don’t mess with the STYLE contents
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.
we can also leverage
wp_kses_hair()(when fixed to rely on the HTML API) and transfer the attributes, but this is tantamount to my suggestion aboveThere 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.
I don't think this is malformed
type_attris something we need to worry about. I did a quick search to see if it is being abused, and I don't see it. If someone were to do something bad with the attribute, then this would be_doing_it_wrong. I've actually been thinking lately that we might want to eliminate the$type_attrentirely as it is obsolete now with HTML5.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.
thanks. I didn’t look into it any further. this appears different in nature as well from some of our other HTML5 theme-support checks: we’re not changing the markup structure, so maybe we can remove it.
there is a case where this could lead to styling change, and that’s when someone is targeting the
STYLEelement based on the presence of thetypeattribute, such asstyle[type~=css], which I think would match or fail to match based on the presence of this attribute.so maybe we propose dropping it entirely and always omit the
type_attrsince there is no place where having it with the privately-set value oftext/csswould lead to different interpretations than not having it.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.
How meta 😄 I'm not aware of style rules having selectors which target other
STYLEtags, but anything is possible. This seems extremely unlikely, however.I would endorse removing the
typeattribute since stylesheets are CSS by default, though this wouldn't have to be done as part of this PR. The same could be done forSCRIPTtags being JavaScript as well, but that's out of scope here. The$type_attris a vestige of the XHTML/HTML4 past.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.
I guess I said styling change but was also thinking more about
document.querySelector(). Either way, I think we are in agreement.Good point about the
<script>type as well, and on doing it in another change.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.
Tasked in Core-64428