tmt-123 opened a new pull request, #13831:
URL: https://github.com/apache/trafficserver/pull/13831

   ## Why
   
   With response body capture enabled (`traffic_dump.so -b`), a valid UTF-8
   response such as `café 中文 😀` is corrupted in the replay JSON on platforms
   where plain `char` is signed. High-bit UTF-8 bytes satisfy the 
control-character
   comparison and are emitted as sign-extended escapes such as `\uffffffc3`.
   A JSON parser can accept that sequence but reconstructs different text.
   
   ## What changed
   
   - Classify input bytes as unsigned before deciding whether JSON escaping is
     required, preserving UTF-8 bytes and existing ASCII escaping.
   - Cover multibyte UTF-8, code-point boundaries, mixed escapes, embedded NUL,
     bounded input, and JSON object/array entry helpers in Catch2.
   - Extend the response-body AuTest with two UTF-8 responses and compare the
     decoded recorded bodies with the original text. Count UTF-8 bytes when
     checking the expected response length.
   
   ## Verification
   
   - Base: `d7964f38559d9a14ae85c8e7025677549a5a2081`.
   - Existing `test_traffic_dump` tests: 3/3 passed before adding regressions.
   - Original production code + new unit tests: 3 UTF-8 test cases failed.
   - Patched `test_traffic_dump`: 6/6 passed.
   - The new response-body AuTest fails on the original plugin after the 
existing
     checks pass; all 7 steps pass with the patched plugin.
   - Related AuTests passed: `traffic_dump`, `traffic_dump_ip_filter`,
     `traffic_dump_response_body`, and `traffic_dump_sni_filter` (4/4).
   - Explicit `-fsigned-char` and `-funsigned-char` builds of the JSON 
production
     code and tests: 42 assertions in 5 test cases passed in each mode.
   - Full CTest: 1,002/1,002 passed after normalizing local Windows checkout
     line endings to LF. The initial 4 failures were caused by CRLF in shell
     scripts and a YAML include fixture; no unrelated code changes were needed.
   - `cmake --build build-dev -t format` and `git diff --check` passed.
   - Tested on Ubuntu 24.04 (WSL), GCC 13.3.0, CMake 3.28.3.
   - Not run: full AuTest suite, HTTP/3, sanitizer builds, or other 
OS/architectures.
   
   This change addresses valid UTF-8 text. It does not introduce a new encoding
   policy for arbitrary non-UTF-8 binary payloads.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to