@angular/platform-browser 5.2.1 → 5.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/animations/animations.metadata.json +1 -1
- package/animations/src/animation_renderer.d.ts +1 -0
- package/animations.d.ts +1 -1
- package/bundles/platform-browser-animations.umd.js +5 -3
- package/bundles/platform-browser-animations.umd.js.map +1 -1
- package/bundles/platform-browser-animations.umd.min.js +2 -2
- package/bundles/platform-browser-animations.umd.min.js.map +1 -1
- package/bundles/platform-browser-testing.umd.js +2 -2
- package/bundles/platform-browser-testing.umd.min.js +2 -2
- package/bundles/platform-browser-testing.umd.min.js.map +1 -1
- package/bundles/platform-browser.umd.js +252 -97
- package/bundles/platform-browser.umd.js.map +1 -1
- package/bundles/platform-browser.umd.min.js +10 -3
- package/bundles/platform-browser.umd.min.js.map +1 -1
- package/esm2015/animations.js +4 -2
- package/esm2015/animations.js.map +1 -1
- package/esm2015/platform-browser.js +213 -93
- package/esm2015/platform-browser.js.map +1 -1
- package/esm2015/testing.js +1 -1
- package/esm5/animations.js +4 -2
- package/esm5/animations.js.map +1 -1
- package/esm5/platform-browser.js +251 -96
- package/esm5/platform-browser.js.map +1 -1
- package/esm5/testing.js +1 -1
- package/package.json +3 -3
- package/platform-browser.metadata.json +1 -1
- package/src/security/inert_body.d.ts +55 -0
- package/testing/testing.metadata.json +1 -1
- package/testing.d.ts +1 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license Angular v5.2.
|
2
|
+
* @license Angular v5.2.5
|
3
3
|
* (c) 2010-2018 Google, Inc. https://angular.io/
|
4
4
|
* License: MIT
|
5
5
|
*/
|
@@ -44,7 +44,7 @@ var __assign = Object.assign || function __assign(t) {
|
|
44
44
|
};
|
45
45
|
|
46
46
|
/**
|
47
|
-
* @license Angular v5.2.
|
47
|
+
* @license Angular v5.2.5
|
48
48
|
* (c) 2010-2018 Google, Inc. https://angular.io/
|
49
49
|
* License: MIT
|
50
50
|
*/
|
@@ -3759,6 +3759,207 @@ var KeyEventsPlugin = /** @class */ (function (_super) {
|
|
3759
3759
|
return KeyEventsPlugin;
|
3760
3760
|
}(EventManagerPlugin));
|
3761
3761
|
|
3762
|
+
/**
|
3763
|
+
* @fileoverview added by tsickle
|
3764
|
+
* @suppress {checkTypes} checked by tsc
|
3765
|
+
*/
|
3766
|
+
/**
|
3767
|
+
* @license
|
3768
|
+
* Copyright Google Inc. All Rights Reserved.
|
3769
|
+
*
|
3770
|
+
* Use of this source code is governed by an MIT-style license that can be
|
3771
|
+
* found in the LICENSE file at https://angular.io/license
|
3772
|
+
*/
|
3773
|
+
/**
|
3774
|
+
* This helper class is used to get hold of an inert tree of DOM elements containing dirty HTML
|
3775
|
+
* that needs sanitizing.
|
3776
|
+
* Depending upon browser support we must use one of three strategies for doing this.
|
3777
|
+
* Support: Safari 10.x -> XHR strategy
|
3778
|
+
* Support: Firefox -> DomParser strategy
|
3779
|
+
* Default: InertDocument strategy
|
3780
|
+
*/
|
3781
|
+
var InertBodyHelper = /** @class */ (function () {
|
3782
|
+
function InertBodyHelper(defaultDoc, DOM) {
|
3783
|
+
this.defaultDoc = defaultDoc;
|
3784
|
+
this.DOM = DOM;
|
3785
|
+
var /** @type {?} */ inertDocument = this.DOM.createHtmlDocument();
|
3786
|
+
this.inertBodyElement = inertDocument.body;
|
3787
|
+
if (this.inertBodyElement == null) {
|
3788
|
+
// usually there should be only one body element in the document, but IE doesn't have any, so
|
3789
|
+
// we need to create one.
|
3790
|
+
var /** @type {?} */ inertHtml = this.DOM.createElement('html', inertDocument);
|
3791
|
+
this.inertBodyElement = this.DOM.createElement('body', inertDocument);
|
3792
|
+
this.DOM.appendChild(inertHtml, this.inertBodyElement);
|
3793
|
+
this.DOM.appendChild(inertDocument, inertHtml);
|
3794
|
+
}
|
3795
|
+
this.DOM.setInnerHTML(this.inertBodyElement, '<svg><g onload="this.parentNode.remove()"></g></svg>');
|
3796
|
+
if (this.inertBodyElement.querySelector && !this.inertBodyElement.querySelector('svg')) {
|
3797
|
+
// We just hit the Safari 10.1 bug - which allows JS to run inside the SVG G element
|
3798
|
+
// so use the XHR strategy.
|
3799
|
+
this.getInertBodyElement = this.getInertBodyElement_XHR;
|
3800
|
+
return;
|
3801
|
+
}
|
3802
|
+
this.DOM.setInnerHTML(this.inertBodyElement, '<svg><p><style><img src="</style><img src=x onerror=alert(1)//">');
|
3803
|
+
if (this.inertBodyElement.querySelector && this.inertBodyElement.querySelector('svg img')) {
|
3804
|
+
// We just hit the Firefox bug - which prevents the inner img JS from being sanitized
|
3805
|
+
// so use the DOMParser strategy, if it is available.
|
3806
|
+
// If the DOMParser is not available then we are not in Firefox (Server/WebWorker?) so we
|
3807
|
+
// fall through to the default strategy below.
|
3808
|
+
if (isDOMParserAvailable()) {
|
3809
|
+
this.getInertBodyElement = this.getInertBodyElement_DOMParser;
|
3810
|
+
return;
|
3811
|
+
}
|
3812
|
+
}
|
3813
|
+
// None of the bugs were hit so it is safe for us to use the default InertDocument strategy
|
3814
|
+
this.getInertBodyElement = this.getInertBodyElement_InertDocument;
|
3815
|
+
}
|
3816
|
+
/**
|
3817
|
+
* Use XHR to create and fill an inert body element (on Safari 10.1)
|
3818
|
+
* See
|
3819
|
+
* https://github.com/cure53/DOMPurify/blob/a992d3a75031cb8bb032e5ea8399ba972bdf9a65/src/purify.js#L439-L449
|
3820
|
+
* @param {?} html
|
3821
|
+
* @return {?}
|
3822
|
+
*/
|
3823
|
+
InertBodyHelper.prototype.getInertBodyElement_XHR = /**
|
3824
|
+
* Use XHR to create and fill an inert body element (on Safari 10.1)
|
3825
|
+
* See
|
3826
|
+
* https://github.com/cure53/DOMPurify/blob/a992d3a75031cb8bb032e5ea8399ba972bdf9a65/src/purify.js#L439-L449
|
3827
|
+
* @param {?} html
|
3828
|
+
* @return {?}
|
3829
|
+
*/
|
3830
|
+
function (html) {
|
3831
|
+
// We add these extra elements to ensure that the rest of the content is parsed as expected
|
3832
|
+
// e.g. leading whitespace is maintained and tags like `<meta>` do not get hoisted to the
|
3833
|
+
// `<head>` tag.
|
3834
|
+
html = '<body><remove></remove>' + html + '</body>';
|
3835
|
+
try {
|
3836
|
+
html = encodeURI(html);
|
3837
|
+
}
|
3838
|
+
catch (/** @type {?} */ e) {
|
3839
|
+
return null;
|
3840
|
+
}
|
3841
|
+
var /** @type {?} */ xhr = new XMLHttpRequest();
|
3842
|
+
xhr.responseType = 'document';
|
3843
|
+
xhr.open('GET', 'data:text/html;charset=utf-8,' + html, false);
|
3844
|
+
xhr.send(null);
|
3845
|
+
var /** @type {?} */ body = xhr.response.body;
|
3846
|
+
body.removeChild(/** @type {?} */ ((body.firstChild)));
|
3847
|
+
return body;
|
3848
|
+
};
|
3849
|
+
/**
|
3850
|
+
* Use DOMParser to create and fill an inert body element (on Firefox)
|
3851
|
+
* See https://github.com/cure53/DOMPurify/releases/tag/0.6.7
|
3852
|
+
*
|
3853
|
+
* @param {?} html
|
3854
|
+
* @return {?}
|
3855
|
+
*/
|
3856
|
+
InertBodyHelper.prototype.getInertBodyElement_DOMParser = /**
|
3857
|
+
* Use DOMParser to create and fill an inert body element (on Firefox)
|
3858
|
+
* See https://github.com/cure53/DOMPurify/releases/tag/0.6.7
|
3859
|
+
*
|
3860
|
+
* @param {?} html
|
3861
|
+
* @return {?}
|
3862
|
+
*/
|
3863
|
+
function (html) {
|
3864
|
+
// We add these extra elements to ensure that the rest of the content is parsed as expected
|
3865
|
+
// e.g. leading whitespace is maintained and tags like `<meta>` do not get hoisted to the
|
3866
|
+
// `<head>` tag.
|
3867
|
+
html = '<body><remove></remove>' + html + '</body>';
|
3868
|
+
try {
|
3869
|
+
var /** @type {?} */ body = /** @type {?} */ (new (/** @type {?} */ (window))
|
3870
|
+
.DOMParser()
|
3871
|
+
.parseFromString(html, 'text/html')
|
3872
|
+
.body);
|
3873
|
+
body.removeChild(/** @type {?} */ ((body.firstChild)));
|
3874
|
+
return body;
|
3875
|
+
}
|
3876
|
+
catch (/** @type {?} */ e) {
|
3877
|
+
return null;
|
3878
|
+
}
|
3879
|
+
};
|
3880
|
+
/**
|
3881
|
+
* Use an HTML5 `template` element, if supported, or an inert body element created via
|
3882
|
+
* `createHtmlDocument` to create and fill an inert DOM element.
|
3883
|
+
* This is the default sane strategy to use if the browser does not require one of the specialised
|
3884
|
+
* strategies above.
|
3885
|
+
* @param {?} html
|
3886
|
+
* @return {?}
|
3887
|
+
*/
|
3888
|
+
InertBodyHelper.prototype.getInertBodyElement_InertDocument = /**
|
3889
|
+
* Use an HTML5 `template` element, if supported, or an inert body element created via
|
3890
|
+
* `createHtmlDocument` to create and fill an inert DOM element.
|
3891
|
+
* This is the default sane strategy to use if the browser does not require one of the specialised
|
3892
|
+
* strategies above.
|
3893
|
+
* @param {?} html
|
3894
|
+
* @return {?}
|
3895
|
+
*/
|
3896
|
+
function (html) {
|
3897
|
+
// Prefer using <template> element if supported.
|
3898
|
+
var /** @type {?} */ templateEl = this.DOM.createElement('template');
|
3899
|
+
if ('content' in templateEl) {
|
3900
|
+
this.DOM.setInnerHTML(templateEl, html);
|
3901
|
+
return templateEl;
|
3902
|
+
}
|
3903
|
+
this.DOM.setInnerHTML(this.inertBodyElement, html);
|
3904
|
+
// Support: IE 9-11 only
|
3905
|
+
// strip custom-namespaced attributes on IE<=11
|
3906
|
+
if (this.defaultDoc.documentMode) {
|
3907
|
+
this.stripCustomNsAttrs(this.inertBodyElement);
|
3908
|
+
}
|
3909
|
+
return this.inertBodyElement;
|
3910
|
+
};
|
3911
|
+
/**
|
3912
|
+
* When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
|
3913
|
+
* attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g.
|
3914
|
+
* 'ns1:xlink:foo').
|
3915
|
+
*
|
3916
|
+
* This is undesirable since we don't want to allow any of these custom attributes. This method
|
3917
|
+
* strips them all.
|
3918
|
+
* @param {?} el
|
3919
|
+
* @return {?}
|
3920
|
+
*/
|
3921
|
+
InertBodyHelper.prototype.stripCustomNsAttrs = /**
|
3922
|
+
* When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
|
3923
|
+
* attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g.
|
3924
|
+
* 'ns1:xlink:foo').
|
3925
|
+
*
|
3926
|
+
* This is undesirable since we don't want to allow any of these custom attributes. This method
|
3927
|
+
* strips them all.
|
3928
|
+
* @param {?} el
|
3929
|
+
* @return {?}
|
3930
|
+
*/
|
3931
|
+
function (el) {
|
3932
|
+
var _this = this;
|
3933
|
+
this.DOM.attributeMap(el).forEach(function (_, attrName) {
|
3934
|
+
if (attrName === 'xmlns:ns1' || attrName.indexOf('ns1:') === 0) {
|
3935
|
+
_this.DOM.removeAttribute(el, attrName);
|
3936
|
+
}
|
3937
|
+
});
|
3938
|
+
for (var _i = 0, _a = this.DOM.childNodesAsList(el); _i < _a.length; _i++) {
|
3939
|
+
var n = _a[_i];
|
3940
|
+
if (this.DOM.isElementNode(n))
|
3941
|
+
this.stripCustomNsAttrs(/** @type {?} */ (n));
|
3942
|
+
}
|
3943
|
+
};
|
3944
|
+
return InertBodyHelper;
|
3945
|
+
}());
|
3946
|
+
/**
|
3947
|
+
* We need to determine whether the DOMParser exists in the global context.
|
3948
|
+
* The try-catch is because, on some browsers, trying to access this property
|
3949
|
+
* on window can actually throw an error.
|
3950
|
+
*
|
3951
|
+
* @suppress {uselessCode}
|
3952
|
+
* @return {?}
|
3953
|
+
*/
|
3954
|
+
function isDOMParserAvailable() {
|
3955
|
+
try {
|
3956
|
+
return !!(/** @type {?} */ (window)).DOMParser;
|
3957
|
+
}
|
3958
|
+
catch (/** @type {?} */ e) {
|
3959
|
+
return false;
|
3960
|
+
}
|
3961
|
+
}
|
3962
|
+
|
3762
3963
|
/**
|
3763
3964
|
* @fileoverview added by tsickle
|
3764
3965
|
* @suppress {checkTypes} checked by tsc
|
@@ -3834,38 +4035,6 @@ function sanitizeSrcset(srcset) {
|
|
3834
4035
|
* Use of this source code is governed by an MIT-style license that can be
|
3835
4036
|
* found in the LICENSE file at https://angular.io/license
|
3836
4037
|
*/
|
3837
|
-
/**
|
3838
|
-
* A <body> element that can be safely used to parse untrusted HTML. Lazily initialized below.
|
3839
|
-
*/
|
3840
|
-
var inertElement = null;
|
3841
|
-
/**
|
3842
|
-
* Lazily initialized to make sure the DOM adapter gets set before use.
|
3843
|
-
*/
|
3844
|
-
var DOM = /** @type {?} */ ((null));
|
3845
|
-
/**
|
3846
|
-
* Returns an HTML element that is guaranteed to not execute code when creating elements in it.
|
3847
|
-
* @return {?}
|
3848
|
-
*/
|
3849
|
-
function getInertElement() {
|
3850
|
-
if (inertElement)
|
3851
|
-
return inertElement;
|
3852
|
-
DOM = getDOM();
|
3853
|
-
// Prefer using <template> element if supported.
|
3854
|
-
var /** @type {?} */ templateEl = DOM.createElement('template');
|
3855
|
-
if ('content' in templateEl)
|
3856
|
-
return templateEl;
|
3857
|
-
var /** @type {?} */ doc = DOM.createHtmlDocument();
|
3858
|
-
inertElement = DOM.querySelector(doc, 'body');
|
3859
|
-
if (inertElement == null) {
|
3860
|
-
// usually there should be only one body element in the document, but IE doesn't have any, so we
|
3861
|
-
// need to create one.
|
3862
|
-
var /** @type {?} */ html = DOM.createElement('html', doc);
|
3863
|
-
inertElement = DOM.createElement('body', doc);
|
3864
|
-
DOM.appendChild(html, inertElement);
|
3865
|
-
DOM.appendChild(doc, html);
|
3866
|
-
}
|
3867
|
-
return inertElement;
|
3868
|
-
}
|
3869
4038
|
/**
|
3870
4039
|
* @param {?} tags
|
3871
4040
|
* @return {?}
|
@@ -3941,6 +4110,7 @@ var SanitizingHtmlSerializer = /** @class */ (function () {
|
|
3941
4110
|
function SanitizingHtmlSerializer() {
|
3942
4111
|
this.sanitizedSomething = false;
|
3943
4112
|
this.buf = [];
|
4113
|
+
this.DOM = getDOM();
|
3944
4114
|
}
|
3945
4115
|
/**
|
3946
4116
|
* @param {?} el
|
@@ -3954,33 +4124,33 @@ var SanitizingHtmlSerializer = /** @class */ (function () {
|
|
3954
4124
|
// This cannot use a TreeWalker, as it has to run on Angular's various DOM adapters.
|
3955
4125
|
// However this code never accesses properties off of `document` before deleting its contents
|
3956
4126
|
// again, so it shouldn't be vulnerable to DOM clobbering.
|
3957
|
-
var /** @type {?} */ current = /** @type {?} */ ((
|
4127
|
+
var /** @type {?} */ current = /** @type {?} */ ((this.DOM.firstChild(el)));
|
3958
4128
|
while (current) {
|
3959
|
-
if (DOM.isElementNode(current)) {
|
4129
|
+
if (this.DOM.isElementNode(current)) {
|
3960
4130
|
this.startElement(/** @type {?} */ (current));
|
3961
4131
|
}
|
3962
|
-
else if (DOM.isTextNode(current)) {
|
3963
|
-
this.chars(/** @type {?} */ ((DOM.nodeValue(current))));
|
4132
|
+
else if (this.DOM.isTextNode(current)) {
|
4133
|
+
this.chars(/** @type {?} */ ((this.DOM.nodeValue(current))));
|
3964
4134
|
}
|
3965
4135
|
else {
|
3966
4136
|
// Strip non-element, non-text nodes.
|
3967
4137
|
this.sanitizedSomething = true;
|
3968
4138
|
}
|
3969
|
-
if (DOM.firstChild(current)) {
|
3970
|
-
current = /** @type {?} */ ((DOM.firstChild(current)));
|
4139
|
+
if (this.DOM.firstChild(current)) {
|
4140
|
+
current = /** @type {?} */ ((this.DOM.firstChild(current)));
|
3971
4141
|
continue;
|
3972
4142
|
}
|
3973
4143
|
while (current) {
|
3974
4144
|
// Leaving the element. Walk up and to the right, closing tags as we go.
|
3975
|
-
if (DOM.isElementNode(current)) {
|
4145
|
+
if (this.DOM.isElementNode(current)) {
|
3976
4146
|
this.endElement(/** @type {?} */ (current));
|
3977
4147
|
}
|
3978
|
-
var /** @type {?} */ next = checkClobberedElement(current, /** @type {?} */ ((DOM.nextSibling(current))));
|
4148
|
+
var /** @type {?} */ next = this.checkClobberedElement(current, /** @type {?} */ ((this.DOM.nextSibling(current))));
|
3979
4149
|
if (next) {
|
3980
4150
|
current = next;
|
3981
4151
|
break;
|
3982
4152
|
}
|
3983
|
-
current = checkClobberedElement(current, /** @type {?} */ ((DOM.parentElement(current))));
|
4153
|
+
current = this.checkClobberedElement(current, /** @type {?} */ ((this.DOM.parentElement(current))));
|
3984
4154
|
}
|
3985
4155
|
}
|
3986
4156
|
return this.buf.join('');
|
@@ -3995,14 +4165,14 @@ var SanitizingHtmlSerializer = /** @class */ (function () {
|
|
3995
4165
|
*/
|
3996
4166
|
function (element) {
|
3997
4167
|
var _this = this;
|
3998
|
-
var /** @type {?} */ tagName = DOM.nodeName(element).toLowerCase();
|
4168
|
+
var /** @type {?} */ tagName = this.DOM.nodeName(element).toLowerCase();
|
3999
4169
|
if (!VALID_ELEMENTS.hasOwnProperty(tagName)) {
|
4000
4170
|
this.sanitizedSomething = true;
|
4001
4171
|
return;
|
4002
4172
|
}
|
4003
4173
|
this.buf.push('<');
|
4004
4174
|
this.buf.push(tagName);
|
4005
|
-
DOM.attributeMap(element).forEach(function (value, attrName) {
|
4175
|
+
this.DOM.attributeMap(element).forEach(function (value, attrName) {
|
4006
4176
|
var /** @type {?} */ lower = attrName.toLowerCase();
|
4007
4177
|
if (!VALID_ATTRS.hasOwnProperty(lower)) {
|
4008
4178
|
_this.sanitizedSomething = true;
|
@@ -4030,7 +4200,7 @@ var SanitizingHtmlSerializer = /** @class */ (function () {
|
|
4030
4200
|
* @return {?}
|
4031
4201
|
*/
|
4032
4202
|
function (current) {
|
4033
|
-
var /** @type {?} */ tagName = DOM.nodeName(current).toLowerCase();
|
4203
|
+
var /** @type {?} */ tagName = this.DOM.nodeName(current).toLowerCase();
|
4034
4204
|
if (VALID_ELEMENTS.hasOwnProperty(tagName) && !VOID_ELEMENTS.hasOwnProperty(tagName)) {
|
4035
4205
|
this.buf.push('</');
|
4036
4206
|
this.buf.push(tagName);
|
@@ -4046,19 +4216,24 @@ var SanitizingHtmlSerializer = /** @class */ (function () {
|
|
4046
4216
|
* @return {?}
|
4047
4217
|
*/
|
4048
4218
|
function (chars) { this.buf.push(encodeEntities(chars)); };
|
4219
|
+
/**
|
4220
|
+
* @param {?} node
|
4221
|
+
* @param {?} nextNode
|
4222
|
+
* @return {?}
|
4223
|
+
*/
|
4224
|
+
SanitizingHtmlSerializer.prototype.checkClobberedElement = /**
|
4225
|
+
* @param {?} node
|
4226
|
+
* @param {?} nextNode
|
4227
|
+
* @return {?}
|
4228
|
+
*/
|
4229
|
+
function (node, nextNode) {
|
4230
|
+
if (nextNode && this.DOM.contains(node, nextNode)) {
|
4231
|
+
throw new Error("Failed to sanitize html because the element is clobbered: " + this.DOM.getOuterHTML(node));
|
4232
|
+
}
|
4233
|
+
return nextNode;
|
4234
|
+
};
|
4049
4235
|
return SanitizingHtmlSerializer;
|
4050
4236
|
}());
|
4051
|
-
/**
|
4052
|
-
* @param {?} node
|
4053
|
-
* @param {?} nextNode
|
4054
|
-
* @return {?}
|
4055
|
-
*/
|
4056
|
-
function checkClobberedElement(node, nextNode) {
|
4057
|
-
if (nextNode && DOM.contains(node, nextNode)) {
|
4058
|
-
throw new Error("Failed to sanitize html because the element is clobbered: " + DOM.getOuterHTML(node));
|
4059
|
-
}
|
4060
|
-
return nextNode;
|
4061
|
-
}
|
4062
4237
|
// Regular Expressions for parsing tags and attributes
|
4063
4238
|
var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
4064
4239
|
// ! to ~ is the ASCII range.
|
@@ -4081,27 +4256,7 @@ function encodeEntities(value) {
|
|
4081
4256
|
.replace(/</g, '<')
|
4082
4257
|
.replace(/>/g, '>');
|
4083
4258
|
}
|
4084
|
-
|
4085
|
-
* When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
|
4086
|
-
* attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g. 'ns1:xlink:foo').
|
4087
|
-
*
|
4088
|
-
* This is undesirable since we don't want to allow any of these custom attributes. This method
|
4089
|
-
* strips them all.
|
4090
|
-
* @param {?} el
|
4091
|
-
* @return {?}
|
4092
|
-
*/
|
4093
|
-
function stripCustomNsAttrs(el) {
|
4094
|
-
DOM.attributeMap(el).forEach(function (_, attrName) {
|
4095
|
-
if (attrName === 'xmlns:ns1' || attrName.indexOf('ns1:') === 0) {
|
4096
|
-
DOM.removeAttribute(el, attrName);
|
4097
|
-
}
|
4098
|
-
});
|
4099
|
-
for (var _i = 0, _a = DOM.childNodesAsList(el); _i < _a.length; _i++) {
|
4100
|
-
var n = _a[_i];
|
4101
|
-
if (DOM.isElementNode(n))
|
4102
|
-
stripCustomNsAttrs(/** @type {?} */ (n));
|
4103
|
-
}
|
4104
|
-
}
|
4259
|
+
var inertBodyHelper;
|
4105
4260
|
/**
|
4106
4261
|
* Sanitizes the given unsafe, untrusted HTML fragment, and returns HTML text that is safe to add to
|
4107
4262
|
* the DOM in a browser environment.
|
@@ -4110,10 +4265,13 @@ function stripCustomNsAttrs(el) {
|
|
4110
4265
|
* @return {?}
|
4111
4266
|
*/
|
4112
4267
|
function sanitizeHtml(defaultDoc, unsafeHtmlInput) {
|
4268
|
+
var /** @type {?} */ DOM = getDOM();
|
4269
|
+
var /** @type {?} */ inertBodyElement = null;
|
4113
4270
|
try {
|
4114
|
-
|
4271
|
+
inertBodyHelper = inertBodyHelper || new InertBodyHelper(defaultDoc, DOM);
|
4115
4272
|
// Make sure unsafeHtml is actually a string (TypeScript types are not enforced at runtime).
|
4116
4273
|
var /** @type {?} */ unsafeHtml = unsafeHtmlInput ? String(unsafeHtmlInput) : '';
|
4274
|
+
inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
|
4117
4275
|
// mXSS protection. Repeatedly parse the document to make sure it stabilizes, so that a browser
|
4118
4276
|
// trying to auto-correct incorrect HTML cannot cause formerly inert HTML to become dangerous.
|
4119
4277
|
var /** @type {?} */ mXSSAttempts = 5;
|
@@ -4124,30 +4282,25 @@ function sanitizeHtml(defaultDoc, unsafeHtmlInput) {
|
|
4124
4282
|
}
|
4125
4283
|
mXSSAttempts--;
|
4126
4284
|
unsafeHtml = parsedHtml;
|
4127
|
-
DOM.
|
4128
|
-
|
4129
|
-
// strip custom-namespaced attributes on IE<=11
|
4130
|
-
stripCustomNsAttrs(containerEl);
|
4131
|
-
}
|
4132
|
-
parsedHtml = DOM.getInnerHTML(containerEl);
|
4285
|
+
parsedHtml = DOM.getInnerHTML(inertBodyElement);
|
4286
|
+
inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
|
4133
4287
|
} while (unsafeHtml !== parsedHtml);
|
4134
4288
|
var /** @type {?} */ sanitizer = new SanitizingHtmlSerializer();
|
4135
|
-
var /** @type {?} */ safeHtml = sanitizer.sanitizeChildren(DOM.getTemplateContent(
|
4136
|
-
// Clear out the body element.
|
4137
|
-
var /** @type {?} */ parent_1 = DOM.getTemplateContent(containerEl) || containerEl;
|
4138
|
-
for (var _i = 0, _a = DOM.childNodesAsList(parent_1); _i < _a.length; _i++) {
|
4139
|
-
var child = _a[_i];
|
4140
|
-
DOM.removeChild(parent_1, child);
|
4141
|
-
}
|
4289
|
+
var /** @type {?} */ safeHtml = sanitizer.sanitizeChildren(DOM.getTemplateContent(inertBodyElement) || inertBodyElement);
|
4142
4290
|
if (_angular_core.isDevMode() && sanitizer.sanitizedSomething) {
|
4143
4291
|
DOM.log('WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).');
|
4144
4292
|
}
|
4145
4293
|
return safeHtml;
|
4146
4294
|
}
|
4147
|
-
|
4295
|
+
finally {
|
4148
4296
|
// In case anything goes wrong, clear out inertElement to reset the entire DOM structure.
|
4149
|
-
|
4150
|
-
|
4297
|
+
if (inertBodyElement) {
|
4298
|
+
var /** @type {?} */ parent_1 = DOM.getTemplateContent(inertBodyElement) || inertBodyElement;
|
4299
|
+
for (var _i = 0, _a = DOM.childNodesAsList(parent_1); _i < _a.length; _i++) {
|
4300
|
+
var child = _a[_i];
|
4301
|
+
DOM.removeChild(parent_1, child);
|
4302
|
+
}
|
4303
|
+
}
|
4151
4304
|
}
|
4152
4305
|
}
|
4153
4306
|
|
@@ -4958,7 +5111,9 @@ var TransferState = /** @class */ (function () {
|
|
4958
5111
|
* @param {?} defaultValue
|
4959
5112
|
* @return {?}
|
4960
5113
|
*/
|
4961
|
-
function (key, defaultValue) {
|
5114
|
+
function (key, defaultValue) {
|
5115
|
+
return this.store[key] !== undefined ? /** @type {?} */ (this.store[key]) : defaultValue;
|
5116
|
+
};
|
4962
5117
|
/**
|
4963
5118
|
* Set the value corresponding to a key.
|
4964
5119
|
*/
|
@@ -5232,7 +5387,7 @@ var By = /** @class */ (function () {
|
|
5232
5387
|
/**
|
5233
5388
|
* \@stable
|
5234
5389
|
*/
|
5235
|
-
var VERSION = new _angular_core.Version('5.2.
|
5390
|
+
var VERSION = new _angular_core.Version('5.2.5');
|
5236
5391
|
|
5237
5392
|
exports.BrowserModule = BrowserModule;
|
5238
5393
|
exports.platformBrowser = platformBrowser;
|