Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 3.2.0
-
Fix Version/s: 3.1.4 (EE only), 3.2.2 (EE only)
-
Component/s: Core: Expressions
-
Labels:None
-
User impact:Medium
-
Similar Issues:None
Description
The result of #[map-payload:key1,key2?] is the expression itself, since the "?" is not escaped when doing regular expression replace in the TemplateParser. This probably affects other situations when optional parameters with "?" are used.
The following test case added to the org.mule.util.TemplateParserTestCase tests for the bug:
/**
*/
@Test
public void testStringParserQuestionMarkInPropertyName()
{
TemplateParser tp = TemplateParser.createAntStyleParser();
Map props = new HashMap();
props.put("prop1?", "value1");
props.put("prop1-2", "value2");
String string = "Some String with ${prop1?} and ${prop1-2} in it";
String result = tp.parse(props, string);
assertEquals("Some String with value1 and value2 in it", result);
}
- Tests replacing properties with question mark in the name.
- This can occur, for instance, when retrieving optional
- keys from a map using the map-payload evaluator.
*/
@Test
public void testStringParserQuestionMarkInPropertyName()
{
TemplateParser tp = TemplateParser.createAntStyleParser();
Map props = new HashMap();
props.put("prop1?", "value1");
props.put("prop1-2", "value2");
String string = "Some String with ${prop1?} and ${prop1-2} in it";
String result = tp.parse(props, string); assertEquals("Some String with value1 and value2 in it", result); }