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

Commit 991a2b3

Browse files
santialbopetebacondarwin
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 ##7897
1 parent fc4afd0 commit 991a2b3

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)