Author: adrianc
Date: Thu Apr 5 14:20:56 2012
New Revision: 1309879
URL:
http://svn.apache.org/viewvc?rev=1309879&view=revLog:
Disable support for nested scripts in FlexibleStringExpander.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java?rev=1309879&r1=1309878&r2=1309879&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java Thu Apr 5 14:20:56 2012
@@ -720,6 +720,9 @@ public abstract class FlexibleStringExpa
String str = (String) obj;
if (str.contains(openBracket)) {
FlexibleStringExpander fse = FlexibleStringExpander.getInstance(str);
+ if (containsScript(fse)) {
+ throw new UnsupportedOperationException("Nested scripts are not supported");
+ }
return fse.get(context, timeZone, locale);
}
} catch (ClassCastException e) {}
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java?rev=1309879&r1=1309878&r2=1309879&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/test/FlexibleStringExpanderTests.java Thu Apr 5 14:20:56 2012
@@ -286,6 +286,16 @@ public class FlexibleStringExpanderTests
List<String> testList = new ArrayList<String>();
testList.add("World");
testMap.put("testList", testList);
+ testMap.put("testScript", "${groovy:return null;}");
+ UnsupportedOperationException caught = null;
+ try {
+ FlexibleStringExpander fse = FlexibleStringExpander.getInstance("${testScript}");
+ fse.expandString(testMap);
+ } catch (UnsupportedOperationException e) {
+ caught = e;
+ } finally {
+ assertNotNull("UnsupportedOperationException thrown for nested script", caught);
+ }
fseTest("null FlexibleStringExpander, null map", null, null, null, null, "", null, true);
fseTest("null FlexibleStringExpander", null, testMap, null, null, "", null, true);
fseTest("null context", "Hello World!", null, null, null, "Hello World!", null, false);