Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-580

Unexpected trimming when value contains escaped delimiter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.9, 1.10
    • None
    • Type conversion
    • None

    Description

      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 split(value,delimiter) which results in
      split(value,delimiter,true) causing the trimming.

      There is a workaround by using the value from another property :

      test1=test\,test
      test2=${test1}\r\n
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            cedricc Cédric Couralet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: