Skip to content

Commit 6c611df

Browse files
committed
fix($compile): whitelist file:// in url sanitization
1 parent 6be24df commit 6c611df

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/ng/compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function $CompileProvider($provide) {
156156
COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\d\w\-_]+)\s+(.*)$/,
157157
CLASS_DIRECTIVE_REGEXP = /(([\d\w\-_]+)(?:\:([^;]+))?;?)/,
158158
MULTI_ROOT_TEMPLATE_ERROR = 'Template must have exactly one root element. was: ',
159-
urlSanitizationWhitelist = /^\s*(https?|ftp|mailto):/;
159+
urlSanitizationWhitelist = /^\s*(https?|ftp|mailto|file):/;
160160

161161

162162
/**

test/ng/compileSpec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,6 +2484,10 @@ describe('$compile', function() {
24842484
$rootScope.testUrl = "mailto:[email protected]";
24852485
$rootScope.$apply();
24862486
expect(element.attr('href')).toBe('mailto:[email protected]');
2487+
2488+
$rootScope.testUrl = "file:///foo/bar.html";
2489+
$rootScope.$apply();
2490+
expect(element.attr('href')).toBe('file:///foo/bar.html');
24872491
}));
24882492

24892493

0 commit comments

Comments
 (0)