Make WordPress Core

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)

theme-name-issue.png​ (282.4 KB ) - added by soyebsalar01 30 hours ago.

Download all attachments as: .zip

Change History (5)

#1 @abcd95
29 hours ago

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.

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 on name and author in wp_ajax_query_themes(), after themes_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 the query-themes Ajax handler.
  • Only text content is changed. Attributes (aria-label, data-name) still use {{ }}, because wp_kses() output is not safe in an attribute.
  • I tested wp_kses() with $themes_allowedtags against common XSS inputs. It removed <script>, <iframe>, <svg onload>, <img onerror>, event handlers, style attributes and javascript: 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 &amp; 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

  1. Go to Appearance → Add Themes.
  2. Search for olive ember. The card and the preview sidebar should show "Olive & Ember".
  3. Search for medicore. The author should show "By Weblizar - WordPress Themes & Plugin".
  4. Check that other theme names and authors still display correctly, and that searching, filtering, previewing and installing still work.

Screenshots

Before After
https://github.com/user-attachments/assets/839c63dc-82bf-4f1d-82fc-b31ee7dc3ef7 https://github.com/user-attachments/assets/d411c586-e014-44c5-9a6b-c3f71ec67205
https://github.com/user-attachments/assets/7e17db18-997b-4972-94a4-3be8e35c2b28 https://github.com/user-attachments/assets/7dfad52b-c015-4407-aa5f-0abae6ce9406
https://github.com/user-attachments/assets/6a4e752b-b93b-469e-9769-9dd15ebed155 https://github.com/user-attachments/assets/71ed14cd-9603-45f2-9d84-40118442f563

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

Note: See TracTickets for help on using tickets.