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

Commit 7b236b2

Browse files
committed
fix($compile): whitelist file:// in url sanitization
1 parent c36933d commit 7b236b2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/ng/compile.js

+1-1
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

+4
Original file line numberDiff line numberDiff line change
@@ -2479,6 +2479,10 @@ describe('$compile', function() {
24792479
$rootScope.testUrl = "mailto:[email protected]";
24802480
$rootScope.$apply();
24812481
expect(element.attr('href')).toBe('mailto:[email protected]');
2482+
2483+
$rootScope.testUrl = "file:///foo/bar.html";
2484+
$rootScope.$apply();
2485+
expect(element.attr('href')).toBe('file:///foo/bar.html');
24822486
}));
24832487

24842488

0 commit comments

Comments
 (0)