Skip to content

Commit c0adcc3

Browse files
committed
refactor($compile): avoid catastrophic backtracking when parsing bindings
This isn't expected to have any actual impact, since AngularJS is only intended to be used in the browser (not the server) and for this RegExp to be exploited by malicious user code the developer would have to have to give the user rights to execute arbitrary JavaScript code anyway. Fixing as a general good practice and to avoid encouraging use of a similar RegExp in other environments where it might actually matter. Closes angular#16464
1 parent 33b251d commit c0adcc3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/ng/compile.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1014,11 +1014,13 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
10141014
var bindingCache = createMap();
10151015

10161016
function parseIsolateBindings(scope, directiveName, isController) {
1017-
var LOCAL_REGEXP = /^\s*([@&<]|=(\*?))(\??)\s*([\w$]*)\s*$/;
1017+
var LOCAL_REGEXP = /^([@&<]|=(\*?))(\??)\s*([\w$]*)$/;
10181018

10191019
var bindings = createMap();
10201020

10211021
forEach(scope, function(definition, scopeName) {
1022+
definition = definition.trim();
1023+
10221024
if (definition in bindingCache) {
10231025
bindings[scopeName] = bindingCache[definition];
10241026
return;

0 commit comments

Comments
 (0)