You've already forked wp-bootstrap
fix: decode WordPress title entities before Twig to prevent double-encoding (v1.0.10)
WordPress's get_the_title() pre-encodes & as &. Twig autoescape re-encoded the & in & to &#038;, rendering as literal & in the browser. Wrapped all 6 get_the_title() calls in ContextBuilder with wp_specialchars_decode() so Twig can properly re-encode once. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
14
CLAUDE.md
14
CLAUDE.md
@@ -234,6 +234,20 @@ Build steps (in order):
|
||||
|
||||
## Session History
|
||||
|
||||
### Session 16 — v1.0.10 Title Double-Encoding Fix (2026-02-25)
|
||||
|
||||
**Completed:** Fixed double-encoding of HTML entities in page titles rendered through Twig.
|
||||
|
||||
**Root cause:** WordPress's `get_the_title()` returns titles with HTML entities pre-encoded (e.g. `&` → `&`). `ContextBuilder` passed these pre-encoded strings to Twig as template variables. Twig's autoescape then re-encoded the `&` in `&` to `&#038;`, which browsers rendered as the literal text `&` instead of `&`. Affected all pages with `&` in their title (e.g. help pages "Bewerbungen & Nachrichten", "Konto & Sicherheit", "Abonnements & Abrechnung").
|
||||
|
||||
**Fix:** Wrapped all 6 `get_the_title()` calls in `ContextBuilder.php` with `wp_specialchars_decode()`. This decodes WordPress entities back to raw characters before Twig, allowing Twig autoescape to properly encode them once. XSS-safe because Twig still escapes all output.
|
||||
|
||||
**Files modified:**
|
||||
|
||||
- `inc/Template/ContextBuilder.php` — `wp_specialchars_decode()` on all 6 `get_the_title()` calls
|
||||
- `style.css` — version bump to 1.0.10
|
||||
- `CHANGELOG.md` — v1.0.10 entry
|
||||
|
||||
### Session 15 — v1.0.9 Performance Optimization (2026-02-19)
|
||||
|
||||
**Completed:** Two targeted performance fixes for production environments.
|
||||
|
||||
Reference in New Issue
Block a user