Repository navigation
Themes: Fix double-escaped theme and author names on the Add Themes screen - #16055
shreyasikhar wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
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. |
Trac ticket: https://core.trac.wordpress.org/ticket/66713
On Appearance → Add Themes, theme names and author names that contain special characters show raw HTML entities. For example, "Olive & Ember" is displayed as "Olive & Ember".
Cause
The WordPress.org Themes API returns these fields already HTML-encoded:
"name": "Olive & Ember""display_name": "Weblizar - WordPress Themes & Plugin"wp_ajax_query_themes()sanitizes both fields withwp_kses()and$themes_allowedtags, so they are sent to the browser as safe HTML. The templates intheme-install.phpthen print them with{{ }}, which escapes them a second time.&becomes&, and the browser shows the literal text&.Fix
The visible theme name and the "By %s" author line in
tmpl-themeandtmpl-theme-previewnow use{{{ }}}, so the values sanitized bywp_kses()are not escaped again. This matches howthemes.phpalready outputsdata.nameanddata.authorfor installed themes, and how this screen already outputsdata.description.Why this is safe
wp_kses()runs onnameandauthorinwp_ajax_query_themes(), afterthemes_api()and its filters. A filtered API response therefore cannot skip sanitization.'themes' => false), so every theme it shows comes from thequery-themesAjax handler.aria-label,data-name) still use{{ }}, becausewp_kses()output is not safe in an attribute.wp_kses()with$themes_allowedtagsagainst common XSS inputs. It removed<script>,<iframe>,<svg onload>,<img onerror>, event handlers,styleattributes andjavascript:URLs, including entity-encoded ones.Known limitation (out of scope)
aria-labelanddata-namestill contain the double-encoded value, so a screen reader announces "Install Olive & Ember". Fixing this needs the value decoded in PHP or JS before it reaches the template. That can be handled in a follow-up.Testing instructions
olive ember. The card and the preview sidebar should show "Olive & Ember".medicore. The author should show "By Weblizar - WordPress Themes & Plugin".Screenshots
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Root-cause analysis, the code change, checking the Themes API data for affected names and authors, and the
wp_kses()safety checks. I reviewed and tested the final change myself.🤖 Generated with Claude Code