Skip to content

Fix StringIndexOutOfBoundsException in CsvUnescaper on lone quote#748

Merged
garydgregory merged 2 commits into
apache:masterfrom
dxbjavid:csv-unescaper-single-quote
Jun 2, 2026
Merged

Fix StringIndexOutOfBoundsException in CsvUnescaper on lone quote#748
garydgregory merged 2 commits into
apache:masterfrom
dxbjavid:csv-unescaper-single-quote

Conversation

@dxbjavid

@dxbjavid dxbjavid commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

StringEscapeUtils.unescapeCsv("\"") throws StringIndexOutOfBoundsException: String index out of range: -1.

A single " passes the "is this a quoted value" check because charAt(0) and charAt(length - 1) read the same character, so CsvUnescaper.translateWhole strips quotes with subSequence(1, length - 1) = subSequence(1, 0). Require length >= 2 so a lone quote falls through unchanged like other unquoted input.

@garydgregory garydgregory changed the title fix StringIndexOutOfBoundsException in CsvUnescaper on lone quote Fix StringIndexOutOfBoundsException in CsvUnescaper on lone quote Jun 2, 2026
@garydgregory garydgregory merged commit e2eb7d1 into apache:master Jun 2, 2026
9 checks passed
@dxbjavid

dxbjavid commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review and merge! Appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants