============================================================================= Gate F: Compact / Indent / HTMLEscape must never panic ============================================================================= runTransformGate asserts that the json transform functions (Compact, Indent, HTMLEscape)
(t *testing.T, data []byte)
| 407 | // - HTMLEscape does NOT validate (it only scans for <, >, &, U+2028, |
| 408 | // U+2029); it must still never panic on adversarial bytes. |
| 409 | func 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 |
no test coverage detected