Skip to content

fix(json): disable HTML escaping when writing JSON files#8090

Merged
olblak merged 4 commits intoupdatecli:mainfrom
loispostula:push-msrwkournuty
Mar 25, 2026
Merged

fix(json): disable HTML escaping when writing JSON files#8090
olblak merged 4 commits intoupdatecli:mainfrom
loispostula:push-msrwkournuty

Conversation

@loispostula
Copy link
Copy Markdown
Contributor

Fix #8089

When the JSON target updates a key, the dasel v1 write path re-serializes the entire file through Go's encoding/json encoder, which defaults to SetEscapeHTML(true). This causes >, <, and & in unrelated string values to be escaped to \u003e, \u003c, \u0026.

For example, updating .volta.node in a package.json corrupts ">0.2%" in the browserslist section to "\u003e0.2%".

The fix adds storage.OptionEscapeHTML: false to the write options in pkg/plugins/utils/dasel/write.go. Dasel v1 already supports this option — it just was never passed.

Test

cd pkg/plugins/resources/json
go test -run TestTargetPreservesSpecialCharacters -v

Additional Information

Checklist

  • I have updated the documentation via pull request in website repository.

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.

loispostula and others added 3 commits March 24, 2026 23:45
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 olblak added bug Something isn't working resource-json labels Mar 25, 2026
@olblak olblak enabled auto-merge (squash) March 25, 2026 07:54
@olblak olblak merged commit 5ea1152 into updatecli:main Mar 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working resource-json

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON target HTML-escapes special characters (> becomes \u003e) when writing with dasel

2 participants