fix(ui): decode $ entity in legacy Story Block editor on reopen (#35782)#36408
Merged
Conversation
The legacy content editor re-encoded `$` to `$` (and backtick to ```) so the value could be safely embedded inside a JS template literal, but only decoded it inside the JSON.parse catch block. Valid Block Editor JSON parses successfully, so the catch never ran and `$` leaked into ProseMirror (and could be re-persisted via JSON.stringify). Decode now happens once, before the try, on both the JSON and markdown-fallback paths. Refs: #35782 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Claude finished @dsolistorres's task in 3m 7s —— View job I'll analyze this and get back to you. |
Contributor
🤖 dotBot Review (Bedrock)Reviewed 1 file(s); 1 candidate(s) → 0 confirmed, 0 uncertain (unverified, kept for review). ✅ No issues found after verification. us.deepseek.r1-v1:0 · Run: #28618371233 · tokens: in: 6498 · out: 2508 · total: 9006 · calls: 3 · est. ~$0.022 |
gortiz-dotcms
approved these changes
Jul 2, 2026
|
Tick the box to add this pull request to the merge queue (same as
|
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.
Proposed Changes
Follow-up to #36346. That PR fixed the backend read boundary so both editors now receive a clean literal
$. This PR fixes the remaining failure in the legacy content editor.Problem
When a Story Block field contains a
$, reopening the content in the legacy content editor showed$50instead of$50(and could re-persist$on save). The new editor was already correct after #36346.Root cause
edit_field.jspre-encodes$→$and backtick →`server-side (line ~220) so the value can be embedded safely inside a JS template literal ($guards against${...}interpolation, backtick against early string termination —StringEscapeUtils.escapeJavaScriptdoes not cover either).The only code that reversed that encoding lived inside the
JSON.parsecatch(the markdown fallback). A real Block Editor value is valid JSON, soJSON.parsesucceeds, thecatchnever runs, and$flowed straight into ProseMirror — and could be re-persisted via theJSON.stringify(content)assignment below.Fix
Decode the template-literal-safety encoding once, before the
try, so both the JSON (Block Editor) and markdown-fallback paths receive a clean value. The now-redundant.replace(...)inside thecatchis removed.This does not weaken the server-side escaping: the
.replace()runs on the already-parsed runtime string, changing data content only — never code structure — so template-literal injection remains neutralized.Checklist
$50now displays correctly on reopen#/#sister-case remains out of scope (intentional, per fix(content-type): decode dollar sign in Story Block JSON on read (#35782) #36346)How to test
The application fee is $50., save + publish$50, not$50Refs: #35782
🤖 Generated with Claude Code
This PR fixes: #35782