Repository navigation
fix: escape JSON RTE output by default (Options.EscapeHtml) - v2.1.0 - #81
Draft
pritesh-jain-cstk wants to merge 20 commits into
Draft
pritesh-jain-cstk wants to merge 20 commits into
pritesh-jain-cstk wants to merge 20 commits into
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
pritesh-jain-cstk
marked this pull request as draft
November 12, 2026 18:28
…s, no URL scheme filter
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.
Summary
The default JSON RTE → HTML renderer (
Utils.JsonToHtml,Utils.GQL.JsonToHtml) and the defaultOptionsrenderer wrote RTE content into HTML without escaping it. This PR escapes it by default, the same way the Java Utils SDK already does, and adds an opt-out so a front end can go back to the previous output if needed.Approach: parity with Java Utils
& < >href/srcStringEscapeUtils.escapeHtml4System.Net.WebUtility.HtmlEncode(built into .NET, no new dependency)There's no hand-written encoder and no URL rewriting.
Changes
Options.EscapeHtml(new, defaulttrue).falserestores the 2.0.x output byte-for-byte; tests check this.Options.EscapeText/Options.EscapeAttribute(new, public): helpers for custom renderers. They followEscapeHtml.RenderNode,RenderMarkandRenderOptionare encoded. Embedded entry/asset titles, UIDs and link text are escaped; for HTML RTE, link text is entity-decoded once first, so it isn't double-escaped.Behavior changes (release notes)
RenderMarknow receives escaped text, and theRenderNodechildren callback returns escaped HTML. Custom renderers that escaped these themselves should stop, or setEscapeHtml = false.&in URLs is written as&, and non-ASCII characters in attributes may be written as numeric entities. Browsers read both the same.Utils.RenderContent(HTML RTE) output is unchanged apart from the embedded objects it replaces.Tests
HtmlEncodingTest.cs: 34 cases covering text, marks, attributes, embedded objects, HTML RTE link text,EscapeHtml = falseand the helpers.