Skip to content

Fix HTML character escaping in JSON output#229

Merged
thepwagner merged 1 commit intoShopify:mainfrom
runlevel5:fix-html-char-escaping
Mar 6, 2026
Merged

Fix HTML character escaping in JSON output#229
thepwagner merged 1 commit intoShopify:mainfrom
runlevel5:fix-html-char-escaping

Conversation

@runlevel5
Copy link
Copy Markdown
Contributor

Preserve <, >, and & characters instead of escaping them to unicode equivalents (\u003c, \u003e, \u0026) during encrypt/decrypt cycle.

Replace json.Marshal with custom quoteBytes implementation that only escapes characters required by JSON spec (quotes, backslashes, control characters) without HTML-safety escaping.

Fixes #226

Preserve <, >, and & characters instead of escaping them to unicode
equivalents (\u003c, \u003e, \u0026) during encrypt/decrypt cycle.

Replace json.Marshal with custom quoteBytes implementation that only
escapes characters required by JSON spec (quotes, backslashes, control
characters) without HTML-safety escaping.
@runlevel5
Copy link
Copy Markdown
Contributor Author

runlevel5 commented Jan 14, 2026

Alternatively we could try to ask upstream github.com/dustin/gojson to have disable characters escaping option but I think it makes more sense to handle this edge case downstream

Copy link
Copy Markdown
Contributor

@thepwagner thepwagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix and the tests — this addresses #226 nicely.

@thepwagner thepwagner merged commit d2cdc46 into Shopify:main Mar 6, 2026
1 check passed
@runlevel5 runlevel5 deleted the fix-html-char-escaping branch March 6, 2026 22:33
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.

Special characters break encrypt/decrypt

2 participants