Repository navigation
Icons: Skip sanitizing the core icons - #85083
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the ⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Should insert content using the global inserter in Undo restores the post selection when another synced entity is loaded (RTC WebSocket) in
|
3529bc2 to
f01a194
Compare
The core icons bundled with the plugin are trusted, and sanitizing them with wp_kses() is the main cost of rendering them.
f01a194 to
f6c20f8
Compare
t-hamano
left a comment
There was a problem hiding this comment.
Thanks for the PR! This is essentially a performance improvement that speeds up loading the core SVG icons, and it doesn't introduce any new APIs, so it would be nice to get it into the 7.2 release.
Overall, it looks good. I left two comments on the core PR:
As a side note, the core icons are already guaranteed to be safe by a unit test. If any harmful code were ever introduced into a core icon, this test would fail:
gutenberg/phpunit/class-wp-icons-registry-gutenberg-test.php
Lines 531 to 542 in 0dabb1c
Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URvdh6RpJUzi7Yz7qYJ
Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URvdh6RpJUzi7Yz7qYJ
Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URvdh6RpJUzi7Yz7qYJ
Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URvdh6RpJUzi7Yz7qYJ
t-hamano
left a comment
There was a problem hiding this comment.
I have applied all the feedback from the core PR here as well.
* Icons: Skip sanitizing the core icons The core icons bundled with the plugin are trusted, and sanitizing them with wp_kses() is the main cost of rendering them. * Icons: Make is_core_icon_file() private Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URvdh6RpJUzi7Yz7qYJ * Icons: Cache the core icon library directory in a private property Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URvdh6RpJUzi7Yz7qYJ * Icons: Test the sanitization of non-core icon files separately Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URvdh6RpJUzi7Yz7qYJ --------- Co-authored-by: fushar <fushar@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
|
I just cherry-picked this PR to the wp/7.2 branch to get it included in the next release: 1d7c9c5 |
* Icons: Skip sanitizing the core icons The core icons bundled with the plugin are trusted, and sanitizing them with wp_kses() is the main cost of rendering them. * Icons: Make is_core_icon_file() private Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URvdh6RpJUzi7Yz7qYJ * Icons: Cache the core icon library directory in a private property Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URvdh6RpJUzi7Yz7qYJ * Icons: Test the sanitization of non-core icon files separately Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URvdh6RpJUzi7Yz7qYJ --------- Co-authored-by: fushar <fushar@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
* Icons: Skip sanitizing the core icons The core icons bundled with the plugin are trusted, and sanitizing them with wp_kses() is the main cost of rendering them. * Icons: Make is_core_icon_file() private Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URvdh6RpJUzi7Yz7qYJ * Icons: Cache the core icon library directory in a private property Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URvdh6RpJUzi7Yz7qYJ * Icons: Test the sanitization of non-core icon files separately Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URvdh6RpJUzi7Yz7qYJ --------- Co-authored-by: fushar <fushar@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
What?
Skips the
wp_kses()sanitization of the core icons bundled with the plugin, inpackages/icons/src/library.Core backport: WordPress/wordpress-develop#14492
Why?
WordPress/wordpress-develop#12270 renders the admin bar and admin menu icons with
wp_get_icon(), so every wp-admin page now loads about 20 icons through the registry. Measurements on that PR show about +3.5 ms of server time per wp-admin page, and most of the icon cost iswp_kses().The core icons ship with the plugin and are as trusted as its PHP files, so sanitizing them does not really protect anything.
How?
WP_Icons_Registry_Gutenberg::get_content()skipssanitize_icon_content()when the icon file is inside the core icon library.Testing Instructions
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: code generation, with my supervision.