Files
Dmitry Verenitsin 3af21e69e5 [mod_json_cdr] Fix malformed JSON in URL-encoded POST bodies (#3152)
`switch_url_encode()` encodes with `double_encode` false, so a `%XX`
already present in `json_text` was emitted unchanged and became
indistinguishable from the escapes the body encoding added itself.
Decoding the body then consumed the values' own escapes as well, and
the document no longer parsed. Values arrive pre-encoded whenever
`encode-values` is on, and can hold percent-hex text regardless of it.

Encode with `switch_url_encode_opt(..., SWITCH_TRUE)` so `%` is encoded
too and the body decodes back to exactly the serialized document.
`mod_xml_cdr` and `mod_format_cdr` already encode their bodies this way.

- Size the escape buffer `* 3 + 1`. `switch_url_encode_opt()` reserves
  the terminator from the length it is given, so `* 3` dropped the last
  escaped character when every byte needed encoding. The base64 call now
  takes that length directly.
- Warn at load when `encode` and `encode-values` are both on, since the
  values stay encoded after the body is decoded.
- Correct both encoding config comments; the `encode` one described only
  `base64`.

Adds core coverage in `tests/unit/switch_utils.c` for both
`switch_url_encode_opt()` modes, its output bounds, and a JSON body
encoded and decoded once.
2026-09-09 18:47:24 +03:00
..
2026-08-08 17:48:05 +03:00
2019-11-21 22:06:14 +04:00
2026-05-26 22:02:42 +03:00
2024-12-03 21:30:46 +01:00
2024-12-03 21:30:46 +01:00
2024-10-11 20:16:39 +02:00
2024-12-03 21:30:46 +01:00
2026-08-08 19:47:47 +03:00
2026-08-08 18:29:25 +03:00
2021-04-27 13:54:32 -06:00
2026-08-08 21:02:15 +03:00
2026-08-08 17:48:05 +03:00
2026-05-26 22:02:42 +03:00
2024-12-03 21:30:46 +01:00

FreeSWITCH unit tests should be kept as shallow unit tests and micro
benchmarks testing functionality exposed through libfreeswitch.

Requirements for a new unit tests: 

1. Tests must use switch_test.h framework