Skip to content

Commit

Permalink
Make sure that loose quote check also looks at the escape characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Henning Schmiedehausen authored and pjankovsky committed Jun 25, 2019
1 parent a9ce6fa commit d5420fa
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.fasterxml.jackson.dataformat.csv.impl;

import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;

import com.fasterxml.jackson.core.io.CharTypes;
import com.fasterxml.jackson.core.io.IOContext;
import com.fasterxml.jackson.dataformat.csv.CsvGenerator;
import com.fasterxml.jackson.dataformat.csv.CsvGenerator.Feature;
import com.fasterxml.jackson.dataformat.csv.CsvSchema;

import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;

/**
* Helper class that handles actual low-level construction of
* CSV output, based only on indexes given without worrying about reordering,
Expand Down Expand Up @@ -1039,8 +1039,14 @@ protected boolean _mayNeedQuotes(String value, int length)
*/
protected final boolean _needsQuotingLoose(String value)
{
char esc1 = _cfgQuoteCharEscapeChar;
char esc2 = _cfgControlCharEscapeChar;

for (int i = 0, len = value.length(); i < len; ++i) {
if (value.charAt(i) < _cfgMinSafeChar) {
char c = value.charAt(i);
if ((c < _cfgMinSafeChar)
|| (c == esc1)
|| (c == esc2)) {
return true;
}
}
Expand Down

0 comments on commit d5420fa

Please sign in to comment.