[ 
https://issues.apache.org/jira/browse/CONFIGURATION-580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14227960#comment-14227960
 ] 

Oliver Heger commented on CONFIGURATION-580:
--------------------------------------------

First of all, sorry that it took so long to get back to this!

I am not sure about the best way to deal with this. I assume the reason for 
this trimming is to handle whitespace around the delimiter character. If you 
have a property declaration like
{{key = value1, value2, value3 ,value4}}
you typically do not want the spaces before or after the delimiter to be part 
of the values.

We could try to be smart and only trim values in the middle of the list, 
leaving out the first and the last value. But I guess, in general it is not 
possible to decide what a specific application wants. So should we make 
trimming more configurable? In version 2.0, there is a new class 
{{DefaultListDelimiterHandler}} which is responsible for list delimiter 
splitting. This class could be initialized with a _trimMode_ and then apply 
different algorithms.

> Unexpected trimming when value contains escaped delimiter
> ---------------------------------------------------------
>
>                 Key: CONFIGURATION-580
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-580
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: Type conversion
>    Affects Versions: 1.9, 1.10
>            Reporter: Cédric Couralet
>            Priority: Minor
>
> When parsing a property string value containing a delimiter character,
> the resulting String is trimmed.
> See the following example :
> {code:java}
> BaseConfiguration conf = new BaseConfiguration();
> conf.setProperty("test1", "test\r\n");
> conf.setProperty("test2", "test\\,test");
> conf.setProperty("test3", "test\\,test\r\n");
> System.out.println("*" + conf.getString("test1") + "*");
> System.out.println("*" + conf.getString("test2") + "*");
> System.out.println("*" + conf.getString("test3") + "*");
> {code}
> Expected :
> {noformat}
> *test
> *
> *test,test*
> *test,test
> *
> {noformat}
> Actual:
> {noformat}
> *test
> *
> *test,test*
> *test,test*
> {noformat}
> This is caused by the {{flatten}} method in {{PropertyConverter}} which calls 
> {{split(value,delimiter)}} which results in
> {{split(value,delimiter,true)}} causing the trimming.
> There is a workaround by using the value from another property :
> {noformat}
> test1=test\,test
> test2=${test1}\r\n
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to