-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Customizer: Allow arbitrary custom CSS #10667
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
Open
sirreal
wants to merge
26
commits into
WordPress:trunk
Choose a base branch
from
sirreal:64418/customizer-allow-arbitrary-custom-css
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.
+32
−54
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
c124eb5
Update wp_custom_css_cb to rely on HTML API for safe SCRIPT tag print…
sirreal e055156
Wrap customizer CSS test in newlines
sirreal 33f9616
Use HTML API for style tags in script-loader
sirreal 606539e
Use HTML Tag Processor to produce WP_Styles style tags
sirreal c938d4c
Use HTML Tag Processor for STYLE tags in theme.php
sirreal dd919f1
Build font style tags with HTML API
sirreal d29900a
PICKME: Update font tests to use semantic HTML comparison
sirreal 6c6a72b
Use HTML API for hide header text
sirreal aad4744
Revert "Use HTML API for hide header text"
sirreal c3ae9a9
Merge branch 'trunk' into styles/use-html-api-for-style-tags
sirreal 4e88745
Fix lint
sirreal d296d6c
Merge branch 'trunk' into styles/use-html-api-for-style-tags
sirreal d8a6f02
Merge branch 'styles/use-html-api-for-style-tags' into 64418/customiz…
sirreal 67500e0
Allow arbitrary customizer custom CSS
sirreal 01b6fb8
Fix lints
sirreal 0141653
Restore STYLE tag trailing newline
sirreal 6585099
Restore STYLE tag trailing newlines in theme.php
sirreal b0020d8
Merge branch 'styles/use-html-api-for-style-tags' into 64418/customiz…
sirreal 407d43f
Move trailing newline out of Tag Processor
sirreal ffd5b45
Merge branch 'styles/use-html-api-for-style-tags' into 64418/customiz…
sirreal 8268865
Merge branch 'trunk' into 64418/customizer-allow-arbitrary-custom-css
sirreal 9e7e04d
Merge branch 'trunk' into 64418/customizer-allow-arbitrary-custom-css
sirreal 879c5d1
Merge branch 'trunk' into 64418/customizer-allow-arbitrary-custom-css
sirreal b340650
Merge branch 'trunk' into 64418/customizer-allow-arbitrary-custom-css
sirreal c5c8507
Update test to remove type attribute
sirreal 6932b6c
Merge branch 'trunk' into 64418/customizer-allow-arbitrary-custom-css
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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -268,6 +268,27 @@ public function test_get_custom_css_post_queries_after_failed_lookup() { | |
| $this->assertSame( get_num_queries(), $queries_before ); | ||
| } | ||
|
|
||
| /** | ||
| * Ensure that dangerous STYLE tag contents do not break HTML output. | ||
| * | ||
| * @ticket 64418 | ||
| */ | ||
| public function test_wp_custom_css_cb_escapes_dangerous_html() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could have the |
||
| wp_update_custom_css_post( | ||
| '*::before { content: "</style><script>alert(1)</script>"; }', | ||
| array( | ||
| 'stylesheet' => $this->setting->stylesheet, | ||
| ) | ||
| ); | ||
| $output = get_echo( 'wp_custom_css_cb' ); | ||
| $expected = <<<'HTML' | ||
| <style id="wp-custom-css"> | ||
| *::before { content: "\3c\2fstyle><script>alert(1)</script>"; } | ||
| </style> | ||
| HTML; | ||
| $this->assertEqualHTML( $expected, $output ); | ||
| } | ||
|
|
||
| /** | ||
| * Test that wp_update_custom_css_post() updates the 'custom_css_post_id' theme mod. | ||
| * | ||
|
|
@@ -373,29 +394,4 @@ public function filter_update_custom_css_data( $data, $args ) { | |
| $data['post_title'] = 'Ignored'; | ||
| return $data; | ||
| } | ||
|
|
||
| /** | ||
| * Tests that validation errors are caught appropriately. | ||
| * | ||
| * Note that the $validity \WP_Error object must be reset each time | ||
| * as it picks up the Errors and passes them to the next assertion. | ||
| * | ||
| * @covers WP_Customize_Custom_CSS_Setting::validate | ||
| */ | ||
| public function test_validate() { | ||
|
|
||
| // Empty CSS throws no errors. | ||
| $result = $this->setting->validate( '' ); | ||
| $this->assertTrue( $result ); | ||
|
|
||
| // Basic, valid CSS throws no errors. | ||
| $basic_css = 'body { background: #f00; } h1.site-title { font-size: 36px; } a:hover { text-decoration: none; } input[type="text"] { padding: 1em; }'; | ||
| $result = $this->setting->validate( $basic_css ); | ||
| $this->assertTrue( $result ); | ||
|
|
||
| // Check for markup. | ||
| $unclosed_comment = $basic_css . '</style>'; | ||
| $result = $this->setting->validate( $unclosed_comment ); | ||
| $this->assertArrayHasKey( 'illegal_markup', $result->errors ); | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.