Skip to content

fix: honor htmlEscape in System.Text.Json ToJson (#680)#702

Open
leno23 wants to merge 1 commit into
MiniProfiler:mainfrom
leno23:fix/stjson-html-escape-680
Open

fix: honor htmlEscape in System.Text.Json ToJson (#680)#702
leno23 wants to merge 1 commit into
MiniProfiler:mainfrom
leno23:fix/stjson-html-escape-680

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 25, 2026

Summary

  • Use JavaScriptEncoder.Default when htmlEscape is true in the STJSON ToJson implementation
  • Keep JavaScriptEncoder.UnsafeRelaxedJsonEscaping as the default for backward-compatible output when htmlEscape is false

Fixes #680

Test plan

  • CI build passes for STJSON target
  • profiler.ToJson(htmlEscape: true) escapes HTML-sensitive characters in serialized output

Use JavaScriptEncoder.Default when htmlEscape is true so STJSON builds
match the Newtonsoft behavior for HTML-safe profiler JSON output.

Fixes MiniProfiler#680

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

htmlEscape property in ToJson using Newtonsoft release 4.5.4

1 participant