fix: escape control characters in native TCP query parameters#1834
fix: escape control characters in native TCP query parameters#1834Laotree wants to merge 9 commits into
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>
SummaryFixes a real correctness bug: string parameters containing tab/newline/CR/backslash/NUL were silently mangled on the native TCP path because Must fix
Should fix
Nits
VerdictRequest changes — the two Must fix items (discarded |
- Fix import grouping in tests/issues/1792_test.go: split external (testify) and internal (clickhouse-go) packages into separate blocks per project convention (stdlib → external → internal) - Fix checkStdMinVersion: handle fmt.Sscanf error instead of discarding both return values; return false on parse failure - Add Test1792StdTCP: std/database-sql coverage over native TCP, completing the 2×2 protocol×API coverage matrix - Switch Test1792Std to db.QueryRowContext(ctx, ...) per documented best practice - Improve single-quote comment in fieldDumpReplacer to explain why it must be escaped (prevents premature string termination in readQuoted) - Add cross-reference comments between httpQueryParamReplacer (conn_http.go) and fieldDumpReplacer (lib/proto/query.go) to make the intentional encoding difference obvious to future maintainers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for the thorough review. All feedback has been addressed in commit 2b7f29c: MUST FIX — resolved
SHOULD FIX — resolved
Nits — resolved
|
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: