From 7b236b29aa3a6f6dfe722815e0a2667d9b7f0899 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 25 Feb 2013 10:02:28 -0800 Subject: [PATCH] fix($compile): whitelist file:// in url sanitization --- src/ng/compile.js | 2 +- test/ng/compileSpec.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 113bacc5afa6..5508605ec999 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -156,7 +156,7 @@ function $CompileProvider($provide) { COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\d\w\-_]+)\s+(.*)$/, CLASS_DIRECTIVE_REGEXP = /(([\d\w\-_]+)(?:\:([^;]+))?;?)/, MULTI_ROOT_TEMPLATE_ERROR = 'Template must have exactly one root element. was: ', - urlSanitizationWhitelist = /^\s*(https?|ftp|mailto):/; + urlSanitizationWhitelist = /^\s*(https?|ftp|mailto|file):/; /** diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 74b1e9e3e6ee..9d0acc22baa0 100644 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -2479,6 +2479,10 @@ describe('$compile', function() { $rootScope.testUrl = "mailto:foo@bar.com"; $rootScope.$apply(); expect(element.attr('href')).toBe('mailto:foo@bar.com'); + + $rootScope.testUrl = "file:///foo/bar.html"; + $rootScope.$apply(); + expect(element.attr('href')).toBe('file:///foo/bar.html'); }));