aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/parse.js
diff options
context:
space:
mode:
authorBrian Nenninger2014-01-02 00:42:59 -0500
committerIgor Minar2014-01-03 14:33:54 -0800
commit3b1a4fe0c83c7898ecd7261ab4213998ee7be0ec (patch)
treeeb4505add3b03825acb170fccc6be24b457c1e8d /src/ng/parse.js
parent9569778f2f5d155ddc9188537e9fb36faaf9dbf1 (diff)
downloadangular.js-3b1a4fe0c83c7898ecd7261ab4213998ee7be0ec.tar.bz2
fix($parse): fix CSP nested property evaluation, and issue that prevented its tests from failing
cspSafeGetterFn incorrectly returned undefined if any of its key parameters were undefined. This wasn't caught by the $parse unit tests because of a timing problem where $ParseProvider was reading the CSP flag before the tests manually set it, so the CSP property evaluation tests never ran. Add test that verifies evaluation of nested properties of multiple lengths. Closes #5591 Closes #5592
Diffstat (limited to 'src/ng/parse.js')
-rw-r--r--src/ng/parse.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/ng/parse.js b/src/ng/parse.js
index 28abe69e..1bd9b0e4 100644
--- a/src/ng/parse.js
+++ b/src/ng/parse.js
@@ -894,16 +894,20 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4, fullExp, options) {
if (pathVal == null) return pathVal;
pathVal = pathVal[key0];
- if (pathVal == null) return key1 ? undefined : pathVal;
+ if (!key1) return pathVal;
+ if (pathVal == null) return undefined;
pathVal = pathVal[key1];
- if (pathVal == null) return key2 ? undefined : pathVal;
+ if (!key2) return pathVal;
+ if (pathVal == null) return undefined;
pathVal = pathVal[key2];
- if (pathVal == null) return key3 ? undefined : pathVal;
+ if (!key3) return pathVal;
+ if (pathVal == null) return undefined;
pathVal = pathVal[key3];
- if (pathVal == null) return key4 ? undefined : pathVal;
+ if (!key4) return pathVal;
+ if (pathVal == null) return undefined;
pathVal = pathVal[key4];
return pathVal;
@@ -924,8 +928,9 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4, fullExp, options) {
}
pathVal = pathVal.$$v;
}
- if (pathVal == null) return key1 ? undefined : pathVal;
+ if (!key1) return pathVal;
+ if (pathVal == null) return undefined;
pathVal = pathVal[key1];
if (pathVal && pathVal.then) {
promiseWarning(fullExp);
@@ -936,8 +941,9 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4, fullExp, options) {
}
pathVal = pathVal.$$v;
}
- if (pathVal == null) return key2 ? undefined : pathVal;
+ if (!key2) return pathVal;
+ if (pathVal == null) return undefined;
pathVal = pathVal[key2];
if (pathVal && pathVal.then) {
promiseWarning(fullExp);
@@ -948,8 +954,9 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4, fullExp, options) {
}
pathVal = pathVal.$$v;
}
- if (pathVal == null) return key3 ? undefined : pathVal;
+ if (!key3) return pathVal;
+ if (pathVal == null) return undefined;
pathVal = pathVal[key3];
if (pathVal && pathVal.then) {
promiseWarning(fullExp);
@@ -960,8 +967,9 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4, fullExp, options) {
}
pathVal = pathVal.$$v;
}
- if (pathVal == null) return key4 ? undefined : pathVal;
+ if (!key4) return pathVal;
+ if (pathVal == null) return undefined;
pathVal = pathVal[key4];
if (pathVal && pathVal.then) {
promiseWarning(fullExp);