this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

all: add tests to cover HTML escaping via encoding/json

Note how the HTML escaping always happens, even when cmd/cue's --escape
flag or the json.HTMLEscape standard library APIs are not used.
This is the bug that the next CL is going to fix, updating the tests.

For #1243.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Iff6cf70e2ce7b5a6f9d7cbf14f3edf390b222e6f
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/552319
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>

+42
+26
cmd/cue/cmd/testdata/script/export_escape.txtar
··· 1 + # Verify that export with and without --escape works as expected. 2 + 3 + exec cue export --out json file.cue 4 + cmp stdout stdout.golden 5 + 6 + exec cue export --out json --escape file.cue 7 + cmp stdout stdout-escape.golden 8 + 9 + -- file.cue -- 10 + package hello 11 + 12 + simple: "hello" 13 + specialJSON: #"\ ""# 14 + specialHTML: "& < >" 15 + -- stdout.golden -- 16 + { 17 + "simple": "hello", 18 + "specialJSON": "\\ \"", 19 + "specialHTML": "\u0026 \u003c \u003e" 20 + } 21 + -- stdout-escape.golden -- 22 + { 23 + "simple": "hello", 24 + "specialJSON": "\\ \"", 25 + "specialHTML": "\u0026 \u003c \u003e" 26 + }
+16
pkg/encoding/json/testdata/gen.txtar
··· 15 15 y: json.Marshal({a: x}) 16 16 } 17 17 t9: json.MarshalStream([{a: 1}, {b: int | *2}]) 18 + t10: json.Marshal({a: #"\ " & < >"#}) 19 + t11: json.HTMLEscape(t10) 20 + t12: json.MarshalStream([{a: #"\ " & < >"#}, {b: ""}]) 21 + t13: json.HTMLEscape(t12) 18 22 19 23 unmarshalStream: { 20 24 t1: json.UnmarshalStream(#"{"a": 1}{"b": 2}"#) ··· 59 63 t9: """ 60 64 {"a":1} 61 65 {"b":2} 66 + 67 + """ 68 + t10: "{\"a\":\"\\\\ \\\" \\u0026 \\u003c \\u003e\"}" 69 + t11: "{\"a\":\"\\\\ \\\" \\u0026 \\u003c \\u003e\"}" 70 + t12: """ 71 + {"a":"\\\\ \\" \\u0026 \\u003c \\u003e"} 72 + {"b":""} 73 + 74 + """ 75 + t13: """ 76 + {"a":"\\\\ \\" \\u0026 \\u003c \\u003e"} 77 + {"b":""} 62 78 63 79 """ 64 80 unmarshalStream: {