MCPcopy Create free account
hub / github.com/buger/jsonparser / runTransformGate

Function runTransformGate

encoding_json_fuzz_test.go:409–428  ·  view source on GitHub ↗

============================================================================= Gate F: Compact / Indent / HTMLEscape must never panic ============================================================================= runTransformGate asserts that the json transform functions (Compact, Indent, HTMLEscape)

(t *testing.T, data []byte)

Source from the content-addressed store, hash-verified

407// - HTMLEscape does NOT validate (it only scans for <, >, &, U+2028,
408// U+2029); it must still never panic on adversarial bytes.
409func runTransformGate(t *testing.T, data []byte) {
410 t.Helper()
411
412 encodingJSONNoPanic(t, "Compact", data, func() {
413 var dst bytes.Buffer
414 // Error is expected on invalid JSON; panic is the only failure.
415 _ = json.Compact(&dst, data)
416 })
417
418 encodingJSONNoPanic(t, "Indent", data, func() {
419 var dst bytes.Buffer
420 _ = json.Indent(&dst, data, "", " ")
421 })
422
423 encodingJSONNoPanic(t, "HTMLEscape", data, func() {
424 var dst bytes.Buffer
425 // HTMLEscape returns no error; it must simply not panic.
426 json.HTMLEscape(&dst, data)
427 })
428}
429
430// =============================================================================
431// Gate H: Streaming Compact/Indent performance on deeply-nested input

Callers 1

runEncodingJSONGatesFunction · 0.85

Calls 1

encodingJSONNoPanicFunction · 0.85

Tested by

no test coverage detected