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

MapConfiguration does not decode escaped Delimiters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.3
    • 1.4
    • None
    • None
    • I think it does not matter because of pure java

    Description

      Hello, I don't know how to reopen resolved bug. See: https://issues.apache.org/jira/browse/CONFIGURATION-30

      There is BAD implementation in MapConfiguration.getProperty(String key) method:

      As "return value" should be list.get(0) instead of "value".
      PropertyConverter.split removes escape chars....

      Suggested correction:

      public Object getProperty(String key)
      {
      Object value = map.get(key);
      if ((value instanceof String) && (!isDelimiterParsingDisabled()))

      { List list = PropertyConverter.split((String) value, getListDelimiter()); //MP: return list.size() > 1 ? list : value; return list.size() > 1 ? list : list.get(0); //MP: split removes escape chars }

      else

      { return value; }

      }

      Test code:

      Map m = new HashMap();
      m.put("foo", "bar
      ,baz");
      m.put("bar", "bar, baz");
      MapConfiguration mc = new MapConfiguration(m);
      mc.setDelimiterParsingDisabled(false);
      mc.setListDelimiter(',');
      Configuration c = mc;
      String bad = c.getString("foo"); //<-- returns "bar
      , baz" expected "bar, baz"
      String ok = c.getString("bar"); // <-- returns "bar"
      System.err.println("Bad: " + bad);
      System.err.println("OK: " + ok);

      Current result is:

      Bad: bar\,baz
      OK: bar

      Attachments

        Activity

          People

            oheger Oliver Heger
            polakm Michal Polak
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: