You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2018/12/11 15:31:00 UTC
[jira] [Commented] (TEXT-149) StringEscapeUtils.unescapeCsv doesn't
remove quotes at begin and end of string
[ https://issues.apache.org/jira/browse/TEXT-149?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16717383#comment-16717383 ]
Gary Gregory commented on TEXT-149:
-----------------------------------
[~kasopey],
Thank you for your report.
Please feel free to provide a PR on GitHub [https://github.com/apache/commons-text/] with a unit test that would fail without the main code change.
Cheers,
Gary
> StringEscapeUtils.unescapeCsv doesn't remove quotes at begin and end of string
> ------------------------------------------------------------------------------
>
> Key: TEXT-149
> URL: https://issues.apache.org/jira/browse/TEXT-149
> Project: Commons Text
> Issue Type: Bug
> Affects Versions: 1.6
> Reporter: Krzysztof Szalast
> Priority: Major
>
> org.apache.commons.text.translate.CsvTranslators:
> {code:java}
> void translateWhole(CharSequence input, Writer out) throws IOException {
> if (input.charAt(0) == '"' && input.charAt(input.length() - 1) == '"') {
> String quoteless = input.subSequence(1, input.length() - 1).toString();
> if (StringUtils.containsAny(quoteless, CsvTranslators.CSV_SEARCH_CHARS)) {
> out.write(StringUtils.replace(quoteless, CsvTranslators.CSV_ESCAPED_QUOTE_STR, CsvTranslators.CSV_QUOTE_STR));
> } else {
> out.write(input.toString());
> }
> } else {
> out.write(input.toString());
> }
> }{code}
>
> In my opinion first occurence "out.write(input.toString());" should be replaced with:
> {code:java}
> out.write(quoteless.toString());{code}
> Because '"' quotes around "input" will be never removed.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)