Skip to content

Fix StringIndexOutOfBoundsException for a lone quote field in DelimitedLineTokenizer - #5522

Open
harrisleesh wants to merge 1 commit into
spring-projects:mainfrom
harrisleesh:GH-5519
Open

harrisleesh wants to merge 1 commit into
spring-projects:mainfrom
harrisleesh:GH-5519

Conversation

@harrisleesh

Copy link
Copy Markdown

Fixes #5519

The quote-wrapping guard in substringWithTrimmedWhitespaceAndQuotesIfQuotesPresent checked the length of the whole line instead of the token, so a one-character token consisting of the quote character itself (e.g. the last field of a,") matched both quote checks with the same character and produced a negative substring range.

This change checks the token length instead, returning a lone quote field literally — consistent with how a lone quote line (tokenize("\"")) is already handled.

Two regression tests added; the field-level one fails on main with StringIndexOutOfBoundsException and passes with the fix. DelimitedLineTokenizerTests passes 44/44.

…edLineTokenizer

The quote-wrapping guard checked the length of the whole line instead
of the token, so a one-character token consisting of the quote
character itself matched both quote checks with the same character and
produced a negative substring range.

Check the token length instead, returning a lone quote field literally,
consistent with how a lone quote line is already handled.

Fixes spring-projects#5519

Signed-off-by: seonghun lee <harrisleesh@gmail.com>
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.

DelimitedLineTokenizer throws StringIndexOutOfBoundsException when a field is a single quote character

1 participant