fix: escape control characters in native TCP query parameters#1834
fix: escape control characters in native TCP query parameters#1834Laotree wants to merge 4 commits intoClickHouse:mainfrom
Conversation
String parameters containing tab, newline, CR, backslash, or NUL were silently truncated when sent via the native TCP protocol. The server decodes parameter values through two stages — readQuoted then deserializeTextEscaped — so control characters must be double-encoded by the client. Replace the single-quote-only ReplaceAll in encodeFieldDump with a strings.Replacer that handles all special characters correctly. Fixes ClickHouse#1792 Signed-off-by: rui cheng <chengrui0428@gmail.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This comment was marked as outdated.
This comment was marked as outdated.
SummaryThis PR fixes a real bug: string query parameters containing tab, newline, CR, backslash, or NUL were silently truncated when sent over the native TCP protocol because the server runs parameter values through two decode stages ( Should fix
Nits
VerdictRequest changes — the fix and unit tests are correct, but HTTP and std API integration test coverage is missing per the project checklist. |
- Replace t.Skip(fmt.Errorf(...)) with t.Skipf(...) and remove unreachable return - Extract shared test cases into controlCharCases to avoid duplication - Add Test1792HTTP: round-trip control characters via HTTP protocol - Add Test1792Std: round-trip control characters via database/sql with clickhouse.Named() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
String parameters containing tab, newline, CR, backslash, or NUL were misinterpreted when sent via the HTTP protocol. The server applies deserializeTextEscaped (TSV format) to param_<name> values, so raw control characters act as field/record delimiters and cause parse errors, and a literal backslash+t is read as a tab. Apply TSV escaping via httpQueryParamReplacer before adding values to the URL query string. Signed-off-by: rui cheng <chengrui0428@gmail.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
String parameters containing tab, newline, CR, backslash, or NUL were silently truncated when sent via the native TCP protocol. The server decodes parameter values through two stages — readQuoted then deserializeTextEscaped — so control characters must be double-encoded by the client. Replace the single-quote-only ReplaceAll in encodeFieldDump with a strings.Replacer that handles all special characters correctly.
Fixes #1792
Summary
Checklist
Delete items not relevant to your PR: