Skip to content

Commit 6ebfff8

Browse files
santialboellimist
authored andcommitted
fix($sce): fix adjustMatcher to replace multiple '*' and '**'
`adjustMatcher` was only replacing the first occurrences of '*' and '**' that were found in whitelisted and blacklisted url strings. Closes #angular#7897
1 parent 4a2670c commit 6ebfff8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/ng/sce.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ function adjustMatcher(matcher) {
4747
'Illegal sequence *** in string matcher. String: {0}', matcher);
4848
}
4949
matcher = escapeForRegexp(matcher).
50-
replace('\\*\\*', '.*').
51-
replace('\\*', '[^:/.?&;]*');
50+
replace(/\\\*\\\*/g, '.*').
51+
replace(/\\\*/g, '[^:/.?&;]*');
5252
return new RegExp('^' + matcher + '$');
5353
} else if (isRegExp(matcher)) {
5454
// The only other type of matcher allowed is a Regexp.

test/ng/sceSpecs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ describe('SCE', function() {
334334
expect(adjustMatcher(/^a.*b$/).exec('a.b')).not.toBeNull();
335335
expect(adjustMatcher(/^a.*b$/).exec('-a.b-')).toBeNull();
336336
});
337+
338+
it('should should match * and **', function() {
339+
expect(adjustMatcher('*://*.example.com/**').exec('http://www.example.com/path')).not.toBeNull();
340+
});
337341
});
338342

339343
describe('regex matcher', function() {

0 commit comments

Comments
 (0)