fix(json): disable HTML escaping when writing JSON files#8090
Merged
olblak merged 4 commits intoupdatecli:mainfrom Mar 25, 2026
Merged
fix(json): disable HTML escaping when writing JSON files#8090olblak merged 4 commits intoupdatecli:mainfrom
olblak merged 4 commits intoupdatecli:mainfrom
Conversation
The dasel v1 JSON writer uses Go's encoding/json which defaults to SetEscapeHTML(true), causing characters like >, <, and & to be escaped to \u003e, \u003c, \u0026 in unrelated string values. Pass storage.OptionEscapeHTML with false to preserve these characters as-is, since JSON files are not an HTML context. Signed-off-by: Loïs Postula <[email protected]>
olblak
reviewed
Mar 25, 2026
olblak
approved these changes
Mar 25, 2026
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.
Fix #8089
When the JSON target updates a key, the dasel v1 write path re-serializes the entire file through Go's
encoding/jsonencoder, which defaults toSetEscapeHTML(true). This causes>,<, and&in unrelated string values to be escaped to\u003e,\u003c,\u0026.For example, updating
.volta.nodein apackage.jsoncorrupts">0.2%"in the browserslist section to"\u003e0.2%".The fix adds
storage.OptionEscapeHTML: falseto the write options inpkg/plugins/utils/dasel/write.go. Dasel v1 already supports this option — it just was never passed.Test
Additional Information
Checklist
Tradeoff
None. There is no valid use case for HTML-escaping characters in JSON files written to disk.
Potential improvement
The write path always goes through dasel v1 even when engine: dasel/v2 is configured. Migrating the write path to dasel v2 would fully retire the v1 dependency.