Conversation
| $this->assertStringNotContainsString( 'width=', $output ); | ||
| $this->assertStringNotContainsString( 'height=', $output ); | ||
| $output = wp_get_icon( 'core/plus', array( 'size' => null ) ); | ||
| $processor = new WP_HTML_Tag_Processor( $output ); |
There was a problem hiding this comment.
This test is updated because stroke-width is now preserved, so checking for the width= string would match it. The attributes are inspected directly instead.
…VG sanitizer. Co-Authored-By: Claude <noreply@anthropic.com>
0ca3a33 to
27b2d08
Compare
|
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. |
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. |
| $stroke_attributes = array( | ||
| 'style' => true, | ||
| 'stroke' => true, | ||
| 'stroke-width' => true, | ||
| 'stroke-linecap' => true, | ||
| 'stroke-linejoin' => true, | ||
| 'stroke-miterlimit' => true, | ||
| 'vector-effect' => true, | ||
| ); |
There was a problem hiding this comment.
Minor: All of these associative arrays can be simplified by using array_fill_keys(), which eliminates the pains of aligning the =>.
| $stroke_attributes = array( | |
| 'style' => true, | |
| 'stroke' => true, | |
| 'stroke-width' => true, | |
| 'stroke-linecap' => true, | |
| 'stroke-linejoin' => true, | |
| 'stroke-miterlimit' => true, | |
| 'vector-effect' => true, | |
| ); | |
| $stroke_attributes = array_fill_keys( | |
| array( | |
| 'style', | |
| 'stroke', | |
| 'stroke-width', | |
| 'stroke-linecap', | |
| 'stroke-linejoin', | |
| 'stroke-miterlimit', | |
| 'vector-effect', | |
| ), | |
| true | |
| ); |
I recall we did this for some other Kses tests already, or we talked about it.
Same goes for the following associative arrays as well.
A helper method could make this more concise, or even a closure in this method:
$generate_array = static function ( string ...$tag_names ): array {
return array_fill_keys( $tag_names, true );
};Then the above can be just:
$stroke_attributes = $generate_array(
'style',
'stroke',
'stroke-width',
'stroke-linecap',
'stroke-linejoin',
'stroke-miterlimit',
'vector-effect',
);There was a problem hiding this comment.
Nice idea. That reminds me of our past discussion. Based on WordPress/gutenberg#75550 (comment), I have decided to use the get_allowed_attribute_list() private method.
Fixed in 706b8a8
… with a helper method. Co-Authored-By: Claude <noreply@anthropic.com>
…SVG sanitizer tests. Co-Authored-By: Claude <noreply@anthropic.com>
…PDoc. Co-Authored-By: Claude <noreply@anthropic.com>
* Icons: Test the registry sanitizer directly with a data provider Mirror the tests from WordPress/wordpress-develop#13559: call `sanitize_icon_content` via reflection with a data provider instead of registering icons from both inline content and a file path. Replace the backport changelog entry for #12197 with one for #13559. Co-Authored-By: Claude <noreply@anthropic.com> * Icons: Align the SVG sanitizer and its tests with the WordPress core backport Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: mcsf <mcsf@git.wordpress.org> Co-authored-by: westonruter <westonruter@git.wordpress.org>
* Icons: Test the registry sanitizer directly with a data provider Mirror the tests from WordPress/wordpress-develop#13559: call `sanitize_icon_content` via reflection with a data provider instead of registering icons from both inline content and a file path. Replace the backport changelog entry for #12197 with one for #13559. Co-Authored-By: Claude <noreply@anthropic.com> * Icons: Align the SVG sanitizer and its tests with the WordPress core backport Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: mcsf <mcsf@git.wordpress.org> Co-authored-by: westonruter <westonruter@git.wordpress.org> Source: WordPress/gutenberg@6db2012
This PR is a subset of #12197, focusing only on allowing the SVG elements and attributes needed for core icons to render correctly.
Related Gutenberg PR:
Trac ticket: https://core.trac.wordpress.org/ticket/65795
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Porting the Gutenberg changes, writing tests, and drafting this description; reviewed by me.
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.