diff options
| author | Tobias Bosch | 2013-11-19 20:42:38 -0800 |
|---|---|---|
| committer | Pete Bacon Darwin | 2013-11-20 23:12:39 +0000 |
| commit | ec3c4f94c79e23c29abcde6e1d2f6eaf05e0664c (patch) | |
| tree | b012206a97beda4a868f2a27a243a643a4f6cd74 /src | |
| parent | 6b8bbe4d90640542eed5607a8c91f6b977b1d6c0 (diff) | |
| download | angular.js-ec3c4f94c79e23c29abcde6e1d2f6eaf05e0664c.tar.bz2 | |
refactor($sce): Use $sniffer instead of $document for feature detection.
Also adds `$sniffer.msieDocumentMode` property.
Closes #4931
Closes #5045
Diffstat (limited to 'src')
| -rw-r--r-- | src/ng/sce.js | 20 | ||||
| -rw-r--r-- | src/ng/sniffer.js | 6 |
2 files changed, 12 insertions, 14 deletions
diff --git a/src/ng/sce.js b/src/ng/sce.js index b1b571c6..24b94c83 100644 --- a/src/ng/sce.js +++ b/src/ng/sce.js @@ -199,8 +199,7 @@ function $SceDelegateProvider() { return resourceUrlBlacklist; }; - this.$get = ['$log', '$document', '$injector', function( - $log, $document, $injector) { + this.$get = ['$injector', function($injector) { var htmlSanitizer = function htmlSanitizer(html) { throw $sceMinErr('unsafe', 'Attempting to use an unsafe value in a safe context.'); @@ -731,18 +730,15 @@ function $SceProvider() { * sce.js and sceSpecs.js would need to be aware of this detail. */ - this.$get = ['$parse', '$document', '$sceDelegate', function( - $parse, $document, $sceDelegate) { + this.$get = ['$parse', '$sniffer', '$sceDelegate', function( + $parse, $sniffer, $sceDelegate) { // Prereq: Ensure that we're not running in IE8 quirks mode. In that mode, IE allows // the "expression(javascript expression)" syntax which is insecure. - if (enabled && msie) { - var documentMode = $document[0].documentMode; - if (documentMode !== undefined && documentMode < 8) { - throw $sceMinErr('iequirks', - 'Strict Contextual Escaping does not support Internet Explorer version < 9 in quirks ' + - 'mode. You can fix this by adding the text <!doctype html> to the top of your HTML ' + - 'document. See http://docs.angularjs.org/api/ng.$sce for more information.'); - } + if (enabled && $sniffer.msie && $sniffer.msieDocumentMode < 8) { + throw $sceMinErr('iequirks', + 'Strict Contextual Escaping does not support Internet Explorer version < 9 in quirks ' + + 'mode. You can fix this by adding the text <!doctype html> to the top of your HTML ' + + 'document. See http://docs.angularjs.org/api/ng.$sce for more information.'); } var sce = copy(SCE_CONTEXTS); diff --git a/src/ng/sniffer.js b/src/ng/sniffer.js index 9a1438d3..0ea8d823 100644 --- a/src/ng/sniffer.js +++ b/src/ng/sniffer.js @@ -22,6 +22,7 @@ function $SnifferProvider() { int((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]), boxee = /Boxee/i.test(($window.navigator || {}).userAgent), document = $document[0] || {}, + documentMode = document.documentMode, vendorPrefix, vendorRegex = /^(Moz|webkit|O|ms)(?=[A-Z])/, bodyStyle = document.body && document.body.style, @@ -66,7 +67,7 @@ function $SnifferProvider() { // jshint +W018 hashchange: 'onhashchange' in $window && // IE8 compatible mode lies - (!document.documentMode || document.documentMode > 7), + (!documentMode || documentMode > 7), hasEvent: function(event) { // IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have // it. In particular the event is not fired when backspace or delete key are pressed or @@ -84,7 +85,8 @@ function $SnifferProvider() { vendorPrefix: vendorPrefix, transitions : transitions, animations : animations, - msie : msie + msie : msie, + msieDocumentMode: documentMode }; }]; } |
