summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-08-15 02:39:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:15:37 -0500
commitc642680e5ba8cf8b58f89f9cad7140b4d1df96e1 (patch)
tree0fbdb74304ca9e0dba68a77c10d2242c94acd52c /source4
parent7d4da6897c547bafbe41cb7acf5dc2fcf387b4bb (diff)
downloadsamba-c642680e5ba8cf8b58f89f9cad7140b4d1df96e1.tar.gz
samba-c642680e5ba8cf8b58f89f9cad7140b4d1df96e1.tar.bz2
samba-c642680e5ba8cf8b58f89f9cad7140b4d1df96e1.zip
r17548: It is a good idea to commit the fix (from mkhl) before the test that
shows the need for... Martin Kuhl writes: The ejs function `substitute_var' returns `undefined' when the first argument ends in a pattern that should be substituted. For that reason, the second assertion fails in the following test-case: ,---- | libinclude("base.js"); | | var obj = new Object(); | obj.FOO = "foo"; | obj.BAR = "bar"; | var str1 = "${FOO}:${BAR}"; | var str2 = "${FOO}:${BAR} "; // note the space after the brace | var sub1 = substitute_var(str1, obj); | var sub2 = substitute_var(str2, obj); | | assert(str1 + " " == str2); | assert(sub1 + " " == sub2); `---- The problem is that the function `split' returns a single-element array in both cases: a) the string to split doesn't contain the split pattern b) the string ends with the split pattern To work around this, the following patch tests this condition and returns `undefined' only if the string to split (`list[i]') really didn't contain a closing brace. (This used to be commit 8a6908200b1e459bc9067a9d1f9635185a7eee16)
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/libjs/base.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/source4/scripting/libjs/base.js b/source4/scripting/libjs/base.js
index fbceabf993..df0bfe0ce9 100644
--- a/source4/scripting/libjs/base.js
+++ b/source4/scripting/libjs/base.js
@@ -72,7 +72,7 @@ function substitute_var(str, subobj)
var i;
for (i=1;i<list.length;i++) {
var list2 = split("}", list[i], 1);
- if (list2.length < 2) {
+ if ((list2.length < 2) && (list2[0] + "}" != list[i])) {
return undefined;
}
var key = list2[0];