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

fix($sce): fix adjustMatcher to replace multiple '*' and '**' #7897

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ng/sce.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function adjustMatcher(matcher) {
'Illegal sequence *** in string matcher. String: {0}', matcher);
}
matcher = escapeForRegexp(matcher).
replace('\\*\\*', '.*').
replace('\\*', '[^:/.?&;]*');
replace(/\\\*\\\*/g, '.*').
replace(/\\\*/g, '[^:/.?&;]*');
return new RegExp('^' + matcher + '$');
} else if (isRegExp(matcher)) {
// The only other type of matcher allowed is a Regexp.
Expand Down
4 changes: 4 additions & 0 deletions test/ng/sceSpecs.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ describe('SCE', function() {
expect(adjustMatcher(/^a.*b$/).exec('a.b')).not.toBeNull();
expect(adjustMatcher(/^a.*b$/).exec('-a.b-')).toBeNull();
});

it('should should match * and **', function() {
expect(adjustMatcher('*://*.example.com/**').exec('http://www.example.com/path')).not.toBeNull();
});
});

describe('regex matcher', function() {
Expand Down