Opened 30 hours ago
Last modified 48 minutes ago
#66713 new defect (bug)
Theme Names Display HTML Entities Instead of Special Characters
| Reported by: | soyebsalar01 | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Themes | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
Some theme names on Appearance → Add Themes are displaying HTML entities such as & instead of their corresponding special characters.
For example, "Olive & Ember" is displayed instead of "Olive & Ember".
Attachments (1)
Change History (5)
This ticket was mentioned in PR #16054 on WordPress/wordpress-develop by @abcd95.
29 hours ago
#2
- Keywords has-patch has-unit-tests added
This ticket was mentioned in PR #16055 on WordPress/wordpress-develop by @shreyasikhar26.
28 hours ago
#3
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:
- Theme name:
"name": "Olive & Ember" - Author:
"display_name": "Weblizar - WordPress Themes & Plugin"
wp_ajax_query_themes() sanitizes both fields with wp_kses() and $themes_allowedtags, so they are sent to the browser as safe HTML. The templates in theme-install.php then 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-theme and tmpl-theme-preview now use {{{ }}}, so the values sanitized by wp_kses() are not escaped again. This matches how themes.php already outputs data.name and data.author for installed themes, and how this screen already outputs data.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.- The page starts with no theme data (
'themes' => false), so every theme it shows comes from thequery-themesAjax handler. - Only text content is changed. Attributes (
aria-label,data-name) still use{{ }}, becausewp_kses()output is not safe in an attribute. - I tested
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-label and data-name still 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
- Go to Appearance → Add Themes.
- Search for
olive ember. The card and the preview sidebar should show "Olive & Ember". - Search for
medicore. The author should show "By Weblizar - WordPress Themes & Plugin". - Check that other theme names and authors still display correctly, and that searching, filtering, previewing and installing still work.
Screenshots
| Before | After |
|---|---|
| | |
| | |
| | |
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
@dhruvang21 commented on PR #16055:
48 minutes ago
#4
@propsbot refresh
Closest related ticket - #27641
I was able to reproduce this 6.9.11, 7.0.8, 7.1.4, and 7.2 Beta 5 trunk. Search Add Themes for olive-ember or thistle-hearth. The literal & shows up in the card, the preview heading, and the Install link’s accessible name.
The name templates date back to [27499], and [28126] added the AJAX path that runs the name through wp_kses() before the template escapes it again. I reproduced the same output with the original 3.9 rendering code. The fix for #27641 covered the description.