Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2023 the original author or authors.
* Copyright 2006-2026 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -218,8 +218,7 @@ private String substringWithTrimmedWhitespaceAndQuotesIfQuotesPresent(String lin

String value;

if ((line.length() >= 2) && isQuoteCharacter(line.charAt(start))
&& isQuoteCharacter(line.charAt(start + len - 1))) {
if ((len >= 2) && isQuoteCharacter(line.charAt(start)) && isQuoteCharacter(line.charAt(start + len - 1))) {
int beginIndex = start + 1;
int endIndex = len - 2;
value = line.substring(beginIndex, beginIndex + endIndex);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2023 the original author or authors.
* Copyright 2006-2026 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -245,6 +245,21 @@ void testTokenizeWithUnclosedQuotes() {
assertEquals("c", line.readString(2));
}

@Test
void testTokenizeWithLoneQuoteCharacterField() {
FieldSet line = tokenizer.tokenize("a,\"");
assertEquals(2, line.getFieldCount());
assertEquals("a", line.readString(0));
assertEquals("\"", line.readString(1));
}

@Test
void testTokenizeWithLoneQuoteCharacterLine() {
FieldSet line = tokenizer.tokenize("\"");
assertEquals(1, line.getFieldCount());
assertEquals("\"", line.readString(0));
}

@Test
void testTokenizeWithSpaceInField() {
FieldSet line = tokenizer.tokenize("a,b ,c");
Expand Down