Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-9

[configuration] PropertiesConfiguration doesn't handle trailing backslashes properly

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      When a .properties file is parsed, we only look at the last character to check
      if the value is spread over several lines, but this is not sufficient. As
      specified by the javadoc for java.util.Properties:

      "Note that it is not sufficient to only examine the character preceding a line
      terminator sequence to see if the line terminator is escaped; there must be an
      odd number of contiguous backslashes for the line terminator to be escaped.
      Since the input is processed from left to right, a non-zero even number of 2n
      contiguous backslashes before a line terminator (or elsewhere) encodes n
      backslashes after escape processing."

      Currently this file:

      key1=abc
      key2=xyz

      is parsed as a file containing a single property:

      key1 -> abc\key2=xyz

      It should be parsed as a configuration containing two properties:

      key1 -> abc\
      key2 -> xyz

        Activity

        Show
        Emmanuel Bourg added a comment - ExtendedProperties in commons-collections is not affected by this bug: http://cvs.apache.org/viewcvs.cgi/jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java?root=Apache-SVN&rev=171380&view=markup It was fixed in 2003: http://cvs.apache.org/viewcvs.cgi?root=Apache-SVN&rev=131114&view=rev
        Hide
        Oliver Heger added a comment -

        This may be a stupid question, but why do we implement our own logic for loading
        properties at all? Why can't we just rely on the Properties class for loading
        the file?

        Show
        Oliver Heger added a comment - This may be a stupid question, but why do we implement our own logic for loading properties at all? Why can't we just rely on the Properties class for loading the file?
        Hide
        Emmanuel Bourg added a comment -

        Simply because we do much more than the standard java.util.Properties.
        PropertiesConfiguration supports interpolation, list properties by repeating the
        same key and file includes.

        Show
        Emmanuel Bourg added a comment - Simply because we do much more than the standard java.util.Properties. PropertiesConfiguration supports interpolation, list properties by repeating the same key and file includes.
        Hide
        Oliver Heger added a comment -

        Fix committed to SVN.

        Show
        Oliver Heger added a comment - Fix committed to SVN.

          People

          • Assignee:
            Unassigned
            Reporter:
            Emmanuel Bourg
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development