Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-85

[configuration] XMLConfiguration does not handle tag names with dots correctly

    Details

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

      Operating System: other
      Platform: Other

      Description

      If an XML file with tag names containing the dot character is loaded by
      XMLConfiguration, access to properties with dots in their name is impossible.
      The dot character is always interpreted as a delimiter character.

      There should be a way of escaping dot characters when they belong to the tag name.

        Activity

        Hide
        Oliver Heger added a comment -

        Created an attachment (id=15535)
        Test case demonstrating the bug

        This patch adds some tags with dots to the test.xml file and then checks
        whether the corresponding property values can be retrieved.

        Show
        Oliver Heger added a comment - Created an attachment (id=15535) Test case demonstrating the bug This patch adds some tags with dots to the test.xml file and then checks whether the corresponding property values can be retrieved.
        Hide
        Oliver Heger added a comment -

        Fixed in SVN.

        Show
        Oliver Heger added a comment - Fixed in SVN.
        Hide
        Emmanuel Bourg added a comment -

        I just looked at the diff, the dot is escaped in the key with another dot, right
        ? What about escaping it with the usual backslash instead ? This would be
        consistent with the way special characters like "=" and ":" are escaped in a key
        of a .properties file. (COM-1321)

        Show
        Emmanuel Bourg added a comment - I just looked at the diff, the dot is escaped in the key with another dot, right ? What about escaping it with the usual backslash instead ? This would be consistent with the way special characters like "=" and ":" are escaped in a key of a .properties file. ( COM-1321 )
        Hide
        Oliver Heger added a comment -

        Right, I used a duplicated dot to do the escaping. I was also thinking about a
        backslash, but I found it inconvenient that in String literals the backslash
        itself has to be escaped. So you would have to write "my
        .elem". This would
        certainly often lead to the error "my\.elem".

        Well, I think it's a question of taste. What about a normal slash? But this is
        uncommon, too.

        Show
        Oliver Heger added a comment - Right, I used a duplicated dot to do the escaping. I was also thinking about a backslash, but I found it inconvenient that in String literals the backslash itself has to be escaped. So you would have to write "my .elem". This would certainly often lead to the error "my\.elem". Well, I think it's a question of taste. What about a normal slash? But this is uncommon, too.
        Hide
        Emmanuel Bourg added a comment -

        You are right, the backslash is less convenient, but on the other other it's the
        usual way to escape stuff in Java.

        Another point, if the user decides to change all delimiters to something else,
        like "/", the double dot notation doesn't make sense anymore. Maybe doubling the
        delimiter would be more correct, that means replacing ESCAPED_DELIMITER in the
        code by PROPERTY_DELIMITER + PROPERTY_DELIMITER.

        Show
        Emmanuel Bourg added a comment - You are right, the backslash is less convenient, but on the other other it's the usual way to escape stuff in Java. Another point, if the user decides to change all delimiters to something else, like "/", the double dot notation doesn't make sense anymore. Maybe doubling the delimiter would be more correct, that means replacing ESCAPED_DELIMITER in the code by PROPERTY_DELIMITER + PROPERTY_DELIMITER.
        Hide
        Oliver Heger added a comment -

        > Another point, if the user decides to change all delimiters to something else,
        > like "/", the double dot notation doesn't make sense anymore. Maybe doubling the
        > delimiter would be more correct, that means replacing ESCAPED_DELIMITER in the
        > code by PROPERTY_DELIMITER + PROPERTY_DELIMITER.

        By "change all delimiters" do you mean by changing the constant's value in the
        source file? I think there are multiple other places in different source files
        where a "." is hardcoded.

        But I agree that PROPERTY_DELIMITER + PROPERTY_DELIMITER would be the correct
        value for the ESCAPED_DELIMITER constant. I can change this unless you insist on
        a backslash (which should not mean that I cannot live with a backslash .

        Show
        Oliver Heger added a comment - > Another point, if the user decides to change all delimiters to something else, > like "/", the double dot notation doesn't make sense anymore. Maybe doubling the > delimiter would be more correct, that means replacing ESCAPED_DELIMITER in the > code by PROPERTY_DELIMITER + PROPERTY_DELIMITER. By "change all delimiters" do you mean by changing the constant's value in the source file? I think there are multiple other places in different source files where a "." is hardcoded. But I agree that PROPERTY_DELIMITER + PROPERTY_DELIMITER would be the correct value for the ESCAPED_DELIMITER constant. I can change this unless you insist on a backslash (which should not mean that I cannot live with a backslash .
        Hide
        Emmanuel Bourg added a comment -

        Oops sorry I thought we already implemented the customizable property delimiters
        Centralizing the hardcoded "." may be a wise move though.

        Let's keep the double delimiter notation, convenience is better.

        Show
        Emmanuel Bourg added a comment - Oops sorry I thought we already implemented the customizable property delimiters Centralizing the hardcoded "." may be a wise move though. Let's keep the double delimiter notation, convenience is better.
        Hide
        Emmanuel Bourg added a comment -
            • COM-2646 has been marked as a duplicate of this bug. ***
        Show
        Emmanuel Bourg added a comment - COM-2646 has been marked as a duplicate of this bug. ***

          People

          • Assignee:
            Unassigned
            Reporter:
            Oliver Heger
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development