diff options
| author | Chirayu Krishnappa | 2013-07-15 12:26:46 -0700 |
|---|---|---|
| committer | Chirayu Krishnappa | 2013-07-19 01:44:57 -0700 |
| commit | b99d064b6ddbcc9f59ea45004279833e9ea82928 (patch) | |
| tree | 94406ce1926027de90a43b4abf4a7c7c8b0651c6 /src/ng/compile.js | |
| parent | 715d97d5c87c9250f8ac8b5801b8c7f3b197e815 (diff) | |
| download | angular.js-b99d064b6ddbcc9f59ea45004279833e9ea82928.tar.bz2 | |
fix(core): parse URLs using the browser's DOM API
Diffstat (limited to 'src/ng/compile.js')
| -rw-r--r-- | src/ng/compile.js | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/ng/compile.js b/src/ng/compile.js index 7d2b6dc7..46ebe71a 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -274,9 +274,9 @@ function $CompileProvider($provide) { this.$get = [ '$injector', '$interpolate', '$exceptionHandler', '$http', '$templateCache', '$parse', - '$controller', '$rootScope', '$document', + '$controller', '$rootScope', '$document', '$$urlUtils', function($injector, $interpolate, $exceptionHandler, $http, $templateCache, $parse, - $controller, $rootScope, $document) { + $controller, $rootScope, $document, $$urlUtils) { var Attributes = function(element, attr) { this.$$element = element; @@ -319,24 +319,23 @@ function $CompileProvider($provide) { } } + nodeName = nodeName_(this.$$element); // sanitize a[href] and img[src] values - nodeName = nodeName_(this.$$element); if ((nodeName === 'A' && key === 'href') || - (nodeName === 'IMG' && key === 'src')){ - urlSanitizationNode.setAttribute('href', value); - - // href property always returns normalized absolute url, so we can match against that - normalizedVal = urlSanitizationNode.href; - if (normalizedVal !== '') { - if ((key === 'href' && !normalizedVal.match(aHrefSanitizationWhitelist)) || - (key === 'src' && !normalizedVal.match(imgSrcSanitizationWhitelist))) { - this[key] = value = 'unsafe:' + normalizedVal; + (nodeName === 'IMG' && key === 'src')) { + // NOTE: $$urlUtils.resolve() doesn't support IE < 8 so we don't sanitize for that case. + if (!msie || msie >= 8 ) { + normalizedVal = $$urlUtils.resolve(value); + if (normalizedVal !== '') { + if ((key === 'href' && !normalizedVal.match(aHrefSanitizationWhitelist)) || + (key === 'src' && !normalizedVal.match(imgSrcSanitizationWhitelist))) { + this[key] = value = 'unsafe:' + normalizedVal; + } } } } - if (writeAttr !== false) { if (value === null || value === undefined) { this.$$element.removeAttr(attrName); |
