From 8f3ab3c4819aef8255f070086bfc54bc051bbe82 Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Wed, 18 Jun 2014 19:24:40 +0100 Subject: [PATCH] fix($sce): fix adjustMatcher to replace multiple '*' and '**' adjustMatcher was only replacing the first '*' and '**' found on the whitelisted and blacklisted urls. --- src/ng/sce.js | 4 ++-- test/ng/sceSpecs.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ng/sce.js b/src/ng/sce.js index d3553bde7c45..c3998949d2d8 100644 --- a/src/ng/sce.js +++ b/src/ng/sce.js @@ -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. diff --git a/test/ng/sceSpecs.js b/test/ng/sceSpecs.js index d3f00d9a010b..12e1597cd03c 100644 --- a/test/ng/sceSpecs.js +++ b/test/ng/sceSpecs.js @@ -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() {