-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Verify that export with and without --escape works as expected. | ||
|
||
exec cue export --out json file.cue | ||
cmp stdout stdout.golden | ||
|
||
exec cue export --out json --escape file.cue | ||
cmp stdout stdout-escape.golden | ||
|
||
-- file.cue -- | ||
package hello | ||
|
||
simple: "hello" | ||
specialJSON: #"\ ""# | ||
specialHTML: "& < >" | ||
-- stdout.golden -- | ||
{ | ||
"simple": "hello", | ||
"specialJSON": "\\ \"", | ||
"specialHTML": "\u0026 \u003c \u003e" | ||
} | ||
-- stdout-escape.golden -- | ||
{ | ||
"simple": "hello", | ||
"specialJSON": "\\ \"", | ||
"specialHTML": "\u0026 \u003c \u003e" | ||
} |
This file contains 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