Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit b30a925

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 #16464
1 parent fe599db commit b30a925

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
@@ -989,11 +989,13 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
989989
var bindingCache = createMap();
990990

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

994994
var bindings = createMap();
995995

996996
forEach(scope, function(definition, scopeName) {
997+
definition = definition.trim();
998+
997999
if (definition in bindingCache) {
9981000
bindings[scopeName] = bindingCache[definition];
9991001
return;

0 commit comments

Comments
 (0)