commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: [LANG] StringUtils.unescapeCsv() allows unpaired embedded double-quote
Date Wed, 05 Nov 2008 13:58:49 GMT
Because the rule is that embedded double-quotes should be doubled.
This is essential when unescaping a CSV list.

For example, suppose one needs to escape the two fields:

abcd","efgh
zyx

This is encoded as

"abcd"",""efgh",xyz

This allows the individual fields to be recovered correctly, as the
unescaper knows that the "" pair is part of the field, not the end of
the field.

If it were

"abcd","efgh",xyz

then the unescaper would see the following fields

abcd
efgh
xyz

If the quoting character (double-quote) is not escaped (by doubling
it) then it's not possible in general to determine what the unescaped
fields should be.

>  -v
>
>
>  On Tue, Nov 4, 2008 at 8:35 PM, sebb <sebbaz@gmail.com> wrote:
>
>  > Just happened to notice that StringUtils.unescapeCsv() does not check
>  > that embedded double-quotes occur in pairs.
>  >
>  > Should this condition be detected, and if so, what should happen?
>  > Throw an Exception? Return the original string untranslated?
>  > Just document the behaviour?
>  >
>  > At present the string <"foo"bar"> is returned as <foo"bar>.
>  >
>
> > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>  > For additional commands, e-mail: dev-help@commons.apache.org
>  >
>  >
>
>
>  --
>  The first right of human is the right of EGO.
>
> --
>  http://www.xperienceexperience.blogspot.com
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message