You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Cédric Couralet <ce...@gmail.com> on 2014/05/26 14:43:30 UTC
[configuration] Unexpected trimming when value contains escaped delimiter
Hello,
When parsing a property string value containing a delimiter character,
the resulting String is trimmed.
See the following example :
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") + "*");
Expected :
*test
*
*test,test*
*test,test
*
Actual:
*test
*
*test,test*
*test,test*
This is caused by the flatten method in PropertyConverter which calls
the split(value,delimiter) which results in
split(value,delimiter,true) causing the trimming.
Is there a way to disable this trimming?
I don't really know if this is expected behavior so I didn't open a
bug report, should I?
Cédric
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [configuration] Unexpected trimming when value contains escaped delimiter
Posted by Cédric Couralet <ce...@gmail.com>.
2014-05-26 21:45 GMT+02:00 Oliver Heger <ol...@oliver-heger.de>:
> Hello Cédric,
>
> Am 26.05.2014 14:43, schrieb Cédric Couralet:
[...]
>> I don't really know if this is expected behavior so I didn't open a
>> bug report, should I?
>
> Splitting at delimiter characters has always been a source for bugs and
> inconsistencies. I think you have discovered one more, so feel free to
> open a bug report in Jira.
thanks, issue created here
https://issues.apache.org/jira/browse/CONFIGURATION-580
And to complete, there is a workaround by using another property value :
test1=titi\,toto
test2=${test1}\r\n
> Note that there is currently ongoing work on a redesigned version 2.0 of
> Commons Configuration. There has also been some changes in the handling
> of list delimiters. I hope that the new design makes it easier to
> customize splitting behavior.
>
> Oliver
>
>>
>> Cédric
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [configuration] Unexpected trimming when value contains escaped
delimiter
Posted by Oliver Heger <ol...@oliver-heger.de>.
Hello Cédric,
Am 26.05.2014 14:43, schrieb Cédric Couralet:
> Hello,
>
> When parsing a property string value containing a delimiter character,
> the resulting String is trimmed.
> See the following example :
> 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") + "*");
>
> Expected :
>
> *test
> *
> *test,test*
> *test,test
> *
>
> Actual:
>
> *test
> *
> *test,test*
> *test,test*
>
> This is caused by the flatten method in PropertyConverter which calls
> the split(value,delimiter) which results in
> split(value,delimiter,true) causing the trimming.
>
> Is there a way to disable this trimming?
> I don't really know if this is expected behavior so I didn't open a
> bug report, should I?
Splitting at delimiter characters has always been a source for bugs and
inconsistencies. I think you have discovered one more, so feel free to
open a bug report in Jira.
Note that there is currently ongoing work on a redesigned version 2.0 of
Commons Configuration. There has also been some changes in the handling
of list delimiters. I hope that the new design makes it easier to
customize splitting behavior.
Oliver
>
> Cédric
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org