You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Michal Polak (JIRA)" <ji...@apache.org> on 2007/03/05 14:03:51 UTC
[jira] Created: (CONFIGURATION-256) MapConfiguration does not
decode escaped Delimiters
MapConfiguration does not decode escaped Delimiters
---------------------------------------------------
Key: CONFIGURATION-256
URL: https://issues.apache.org/jira/browse/CONFIGURATION-256
Project: Commons Configuration
Issue Type: Bug
Affects Versions: 1.3
Environment: I think it does not matter because of pure java
Reporter: Michal Polak
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
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (CONFIGURATION-256) MapConfiguration does not
decode escaped Delimiters
Posted by "Michal Polak (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-256?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michal Polak updated CONFIGURATION-256:
---------------------------------------
I think same bugs are in:
AppletConfiguration.getProperty
ServletConfiguration.getProperty
ServletContextConfiguration.getProperty
ServletFilterConfiguration.getProperty
Variable 'value' still contains backslashes as escape chars.
Backslashes are removed by PropertyConverter.split
Property and XML configuration are OK, I think.
> MapConfiguration does not decode escaped Delimiters
> ---------------------------------------------------
>
> Key: CONFIGURATION-256
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-256
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.3
> Environment: I think it does not matter because of pure java
> Reporter: Michal Polak
>
> 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
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Resolved: (CONFIGURATION-256) MapConfiguration does not
decode escaped Delimiters
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-256?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oliver Heger resolved CONFIGURATION-256.
----------------------------------------
Resolution: Fixed
Fix Version/s: 1.4
MapConfiguration and all the web-based configurations were updated to correctly remove the escaping character for the list delimiter. Additional tests were added to verify this behavior.
Please double-check. Thanks.
> MapConfiguration does not decode escaped Delimiters
> ---------------------------------------------------
>
> Key: CONFIGURATION-256
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-256
> Project: Commons Configuration
> Issue Type: Bug
> Affects Versions: 1.3
> Environment: I think it does not matter because of pure java
> Reporter: Michal Polak
> Assigned To: Oliver Heger
> Fix For: 1.4
>
>
> 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
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org