Skip to content

Backport(v1.19): parser_csv: fix the fast engine for quoted values that contain the delimiter and an escaped quote (#5667) - #5700

Merged
Watson1978 merged 1 commit into
v1.19from
backport-to-v1.19/pr5667
Nov 30, 2026
Merged

Watson1978 merged 1 commit into
v1.19from
backport-to-v1.19/pr5667

Conversation

@github-actions

Copy link
Copy Markdown

Which issue(s) this PR fixes:
Backport #5667
Fixes #5666

What this PR does / why we need it:
With parser_engine fast, a quoted value that has both the delimiter and an escaped "" came out wrong. The joining of split pieces only kicked in when the first piece had exactly one quote and stopped at the first piece ending with a quote, so "" before a comma ended the value early and pushed the rest into the next keys. The joined value also never got "" unescaped.

Lines without two consecutive double quotes use the existing field-handling logic. In other lines, a split piece that starts with a quote and has an odd quote count is a candidate for a quoted field spanning multiple pieces. The parser uses byte offsets to check the pieces. If it finds a well-formed field, it joins the pieces once and unescapes doubled quotes. Otherwise it falls back to the existing handling for the starting piece. The tests cover valid escaped quotes, the full records for three malformed inputs, long lines, and a quoted value that has the delimiter but no escaped quote.

Docs Changes:
None

Release Note:
parser_csv: fix the fast engine for quoted values that contain the delimiter and an escaped quote

…limiter and an escaped quote (#5667)

With parser_engine fast, a quoted value that has both the delimiter and
an escaped "" came out wrong. The join of split pieces started only
when the first piece had exactly one quote, and it stopped at the first
piece ending with a quote. So "" before the delimiter ended the value
early and pushed the rest into the next keys. The joined value also
kept "" escaped.

Lines without two consecutive double quotes still use the existing
field handling. In other lines, a piece that starts with a quote and
has an odd quote count may start a quoted field that spans several
pieces. The parser checks the pieces by byte offsets, so long and
multibyte lines stay linear. If it finds a well-formed field, it joins
the pieces once and unescapes doubled quotes. Otherwise the starting
piece is handled as before.

Fixes #5666

Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
Co-authored-by: Shizuo Fujita <fujita@clear-code.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@Watson1978 Watson1978 added the bug Something isn't working label Nov 30, 2026
@Watson1978 Watson1978 added this to the v1.19.5 milestone Nov 30, 2026
@Watson1978
Watson1978 merged commit 51071c2 into v1.19 Nov 30, 2026
21 checks passed
@Watson1978
Watson1978 deleted the backport-to-v1.19/pr5667 branch November 30, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants