fix: decode html entities in widget titles - #409
Merged
AllTerrainDeveloper merged 2 commits intoJul 24, 2026
Conversation
AllTerrainDeveloper
approved these changes
Jul 24, 2026
AllTerrainDeveloper
left a comment
Collaborator
There was a problem hiding this comment.
Thank you very much!
Comment on lines
+416
to
+425
|
|
||
| /** | ||
| * Decode HTML entities from a string cleanly using a temporary textarea. | ||
| */ | ||
| export function decodeHTML( raw: string ): string { | ||
| const ta = document.createElement( 'textarea' ); | ||
| ta.innerHTML = raw; | ||
| return ta.value; | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #393
Description
This PR fixes a visual bug where HTML entities in post titles (e.g.
&or’) were rendered raw inside built-in desktop widgets (such as Recent Comments and the Starter Widget).Root Causes & Fixes
Missing Entity Decoding in Widgets:
Issue: The REST API returns titles with HTML-encoded entities in the
title.renderedpayload. The widgets were setting this raw payload directly totextContent, causing the browser to render the raw entity codes (likeQ&A: User’s Guide).Fix: Created a shared utility
decodeHTMLinsideutils.tsthat safely decodes HTML entities by parsing them through a temporary DOMtextareaelement. Bothrecent-comments-widget/index.tsandstarter-widget/index.tsnow import and applydecodeHTMLto titles before updating the UI.Code Duplication:
Issue: The Posts window already had a local
decodeTitlefunction doing identical DOM-based decoding, creating redundant code.Fix: Refactored
posts-window/index.tsto import and reuse the shareddecodeHTMLutility fromutils.ts.Verification
Build:
npm run buildcompleted successfully.Typecheck:
npm run typecheckpassed with no errors.Unit Tests:
npm run test:jsandnpm run test:phpboth completed successfully with all tests passing (1601/1601 JS tests and 1017/1017 PHP tests).Before fix
↳ Q&A: User’s GuideAfter fix
↳ Q&A: User’s Guide