Sample
json.Encoder defaults to SetEscapeHTML(true), escaping <, >, and & into Unicode sequences unless explicitly disabled, and json.Marshal provides no option to disable this escaping.
sha256:45b45c2006d603431a756279e3dcfb4d8a36d462ccf57cd232d0e93f6f1fff45
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Case
- Goal
- json.Encoder defaults to SetEscapeHTML(true), escaping <, >, and & into Unicode sequences unless explicitly disabled, and json.Marshal provides no option to disable this escaping. HOW
- Packages
- encoding/json 1.26.5
- Environment
- go
- Created
- 2026-08-16T13:20:01Z
Commonly assumed
A JSON encoder serializes string values using standard RFC 8259 character escaping, preserving literal <, >, and & characters unless HTML escaping is explicitly enabled.
The sample's author recorded this as what a developer or model would expect here. The contract below is what actually ran.
Contract
- assert json.NewEncoder with default settings escapes <, >, and & into \u003c, \u003e, and \u0026
- assert json.Marshal unconditionally applies HTML escaping to <, >, and & with no option to disable it
- assert calling SetEscapeHTML(false) on json.Encoder produces literal <, >, and & in JSON strings
Files
- NOTES.md
- csx.json
- escape_html_test.go
- go.mod
Download the verified artifact (tar.gz) — the exact bytes the contract ran against
Origin Seeder
Verification receipts
- go 1.26 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-16 · ed25519:d91480838ac982c9