@angular/platform-browser 4.4.3 → 4.4.7
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/@angular/platform-browser/animations.es5.js +1 -1
- package/@angular/platform-browser/animations.js +1 -1
- package/@angular/platform-browser/testing.es5.js +1 -1
- package/@angular/platform-browser/testing.js +1 -1
- package/@angular/platform-browser.es5.js +210 -99
- package/@angular/platform-browser.es5.js.map +1 -1
- package/@angular/platform-browser.js +206 -96
- package/@angular/platform-browser.js.map +1 -1
- package/animations.d.ts +1 -1
- package/bundles/platform-browser-animations.umd.js +2 -2
- 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 +3 -3
- package/bundles/platform-browser-testing.umd.min.js.map +1 -1
- package/bundles/platform-browser.umd.js +211 -100
- package/bundles/platform-browser.umd.js.map +1 -1
- package/bundles/platform-browser.umd.min.js +15 -8
- package/bundles/platform-browser.umd.min.js.map +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.d.ts +1 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license Angular v4.4.
|
2
|
+
* @license Angular v4.4.7
|
3
3
|
* (c) 2010-2017 Google, Inc. https://angular.io/
|
4
4
|
* License: MIT
|
5
5
|
*/
|
@@ -36,7 +36,7 @@ function __extends(d, b) {
|
|
36
36
|
}
|
37
37
|
|
38
38
|
/**
|
39
|
-
* @license Angular v4.4.
|
39
|
+
* @license Angular v4.4.7
|
40
40
|
* (c) 2010-2017 Google, Inc. https://angular.io/
|
41
41
|
* License: MIT
|
42
42
|
*/
|
@@ -146,8 +146,6 @@ var DomAdapter = (function () {
|
|
146
146
|
enumerable: true,
|
147
147
|
configurable: true
|
148
148
|
});
|
149
|
-
|
150
|
-
|
151
149
|
/**
|
152
150
|
* @abstract
|
153
151
|
* @param {?} nodeA
|
@@ -2513,7 +2511,6 @@ var EventManagerPlugin = (function () {
|
|
2513
2511
|
}
|
2514
2512
|
return this.addEventListener(target, eventName, handler);
|
2515
2513
|
};
|
2516
|
-
|
2517
2514
|
return EventManagerPlugin;
|
2518
2515
|
}());
|
2519
2516
|
/**
|
@@ -2701,7 +2698,6 @@ var DomRendererFactory2 = (function () {
|
|
2701
2698
|
this.rendererByCompId = new Map();
|
2702
2699
|
this.defaultRenderer = new DefaultDomRenderer2(eventManager);
|
2703
2700
|
}
|
2704
|
-
|
2705
2701
|
/**
|
2706
2702
|
* @param {?} element
|
2707
2703
|
* @param {?} type
|
@@ -3381,6 +3377,174 @@ KeyEventsPlugin.decorators = [
|
|
3381
3377
|
KeyEventsPlugin.ctorParameters = function () { return [
|
3382
3378
|
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1,] },] },
|
3383
3379
|
]; };
|
3380
|
+
/**
|
3381
|
+
* @license
|
3382
|
+
* Copyright Google Inc. All Rights Reserved.
|
3383
|
+
*
|
3384
|
+
* Use of this source code is governed by an MIT-style license that can be
|
3385
|
+
* found in the LICENSE file at https://angular.io/license
|
3386
|
+
*/
|
3387
|
+
/**
|
3388
|
+
* This helper class is used to get hold of an inert tree of DOM elements containing dirty HTML
|
3389
|
+
* that needs sanitizing.
|
3390
|
+
* Depending upon browser support we must use one of three strategies for doing this.
|
3391
|
+
* Support: Safari 10.x -> XHR strategy
|
3392
|
+
* Support: Firefox -> DomParser strategy
|
3393
|
+
* Default: InertDocument strategy
|
3394
|
+
*/
|
3395
|
+
var InertBodyHelper = (function () {
|
3396
|
+
/**
|
3397
|
+
* @param {?} defaultDoc
|
3398
|
+
* @param {?} DOM
|
3399
|
+
*/
|
3400
|
+
function InertBodyHelper(defaultDoc, DOM) {
|
3401
|
+
this.defaultDoc = defaultDoc;
|
3402
|
+
this.DOM = DOM;
|
3403
|
+
var inertDocument = this.DOM.createHtmlDocument();
|
3404
|
+
this.inertBodyElement = inertDocument.body;
|
3405
|
+
if (this.inertBodyElement == null) {
|
3406
|
+
// usually there should be only one body element in the document, but IE doesn't have any, so
|
3407
|
+
// we need to create one.
|
3408
|
+
var inertHtml = this.DOM.createElement('html', inertDocument);
|
3409
|
+
this.inertBodyElement = this.DOM.createElement('body', inertDocument);
|
3410
|
+
this.DOM.appendChild(inertHtml, this.inertBodyElement);
|
3411
|
+
this.DOM.appendChild(inertDocument, inertHtml);
|
3412
|
+
}
|
3413
|
+
this.DOM.setInnerHTML(this.inertBodyElement, '<svg><g onload="this.parentNode.remove()"></g></svg>');
|
3414
|
+
if (this.inertBodyElement.querySelector && !this.inertBodyElement.querySelector('svg')) {
|
3415
|
+
// We just hit the Safari 10.1 bug - which allows JS to run inside the SVG G element
|
3416
|
+
// so use the XHR strategy.
|
3417
|
+
this.getInertBodyElement = this.getInertBodyElement_XHR;
|
3418
|
+
return;
|
3419
|
+
}
|
3420
|
+
this.DOM.setInnerHTML(this.inertBodyElement, '<svg><p><style><img src="</style><img src=x onerror=alert(1)//">');
|
3421
|
+
if (this.inertBodyElement.querySelector && this.inertBodyElement.querySelector('svg img')) {
|
3422
|
+
// We just hit the Firefox bug - which prevents the inner img JS from being sanitized
|
3423
|
+
// so use the DOMParser strategy, if it is available.
|
3424
|
+
// If the DOMParser is not available then we are not in Firefox (Server/WebWorker?) so we
|
3425
|
+
// fall through to the default strategy below.
|
3426
|
+
if (isDOMParserAvailable()) {
|
3427
|
+
this.getInertBodyElement = this.getInertBodyElement_DOMParser;
|
3428
|
+
return;
|
3429
|
+
}
|
3430
|
+
}
|
3431
|
+
// None of the bugs were hit so it is safe for us to use the default InertDocument strategy
|
3432
|
+
this.getInertBodyElement = this.getInertBodyElement_InertDocument;
|
3433
|
+
}
|
3434
|
+
/**
|
3435
|
+
* Use XHR to create and fill an inert body element (on Safari 10.1)
|
3436
|
+
* See
|
3437
|
+
* https://github.com/cure53/DOMPurify/blob/a992d3a75031cb8bb032e5ea8399ba972bdf9a65/src/purify.js#L439-L449
|
3438
|
+
* @param {?} html
|
3439
|
+
* @return {?}
|
3440
|
+
*/
|
3441
|
+
InertBodyHelper.prototype.getInertBodyElement_XHR = function (html) {
|
3442
|
+
// We add these extra elements to ensure that the rest of the content is parsed as expected
|
3443
|
+
// e.g. leading whitespace is maintained and tags like `<meta>` do not get hoisted to the
|
3444
|
+
// `<head>` tag.
|
3445
|
+
html = '<body><remove></remove>' + html + '</body>';
|
3446
|
+
try {
|
3447
|
+
html = encodeURI(html);
|
3448
|
+
}
|
3449
|
+
catch (e) {
|
3450
|
+
return null;
|
3451
|
+
}
|
3452
|
+
var /** @type {?} */ xhr = new XMLHttpRequest();
|
3453
|
+
xhr.responseType = 'document';
|
3454
|
+
xhr.open('GET', 'data:text/html;charset=utf-8,' + html, false);
|
3455
|
+
xhr.send(null);
|
3456
|
+
var /** @type {?} */ body = xhr.response.body;
|
3457
|
+
body.removeChild(/** @type {?} */ ((body.firstChild)));
|
3458
|
+
return body;
|
3459
|
+
};
|
3460
|
+
/**
|
3461
|
+
* Use DOMParser to create and fill an inert body element (on Firefox)
|
3462
|
+
* See https://github.com/cure53/DOMPurify/releases/tag/0.6.7
|
3463
|
+
*
|
3464
|
+
* @param {?} html
|
3465
|
+
* @return {?}
|
3466
|
+
*/
|
3467
|
+
InertBodyHelper.prototype.getInertBodyElement_DOMParser = function (html) {
|
3468
|
+
// We add these extra elements to ensure that the rest of the content is parsed as expected
|
3469
|
+
// e.g. leading whitespace is maintained and tags like `<meta>` do not get hoisted to the
|
3470
|
+
// `<head>` tag.
|
3471
|
+
html = '<body><remove></remove>' + html + '</body>';
|
3472
|
+
try {
|
3473
|
+
var /** @type {?} */ body = (new ((window))
|
3474
|
+
.DOMParser()
|
3475
|
+
.parseFromString(html, 'text/html')
|
3476
|
+
.body);
|
3477
|
+
body.removeChild(/** @type {?} */ ((body.firstChild)));
|
3478
|
+
return body;
|
3479
|
+
}
|
3480
|
+
catch (e) {
|
3481
|
+
return null;
|
3482
|
+
}
|
3483
|
+
};
|
3484
|
+
/**
|
3485
|
+
* Use an HTML5 `template` element, if supported, or an inert body element created via
|
3486
|
+
* `createHtmlDocument` to create and fill an inert DOM element.
|
3487
|
+
* This is the default sane strategy to use if the browser does not require one of the specialised
|
3488
|
+
* strategies above.
|
3489
|
+
* @param {?} html
|
3490
|
+
* @return {?}
|
3491
|
+
*/
|
3492
|
+
InertBodyHelper.prototype.getInertBodyElement_InertDocument = function (html) {
|
3493
|
+
// Prefer using <template> element if supported.
|
3494
|
+
var /** @type {?} */ templateEl = this.DOM.createElement('template');
|
3495
|
+
if ('content' in templateEl) {
|
3496
|
+
this.DOM.setInnerHTML(templateEl, html);
|
3497
|
+
return templateEl;
|
3498
|
+
}
|
3499
|
+
this.DOM.setInnerHTML(this.inertBodyElement, html);
|
3500
|
+
// Support: IE 9-11 only
|
3501
|
+
// strip custom-namespaced attributes on IE<=11
|
3502
|
+
if (this.defaultDoc.documentMode) {
|
3503
|
+
this.stripCustomNsAttrs(this.inertBodyElement);
|
3504
|
+
}
|
3505
|
+
return this.inertBodyElement;
|
3506
|
+
};
|
3507
|
+
/**
|
3508
|
+
* When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
|
3509
|
+
* attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g.
|
3510
|
+
* 'ns1:xlink:foo').
|
3511
|
+
*
|
3512
|
+
* This is undesirable since we don't want to allow any of these custom attributes. This method
|
3513
|
+
* strips them all.
|
3514
|
+
* @param {?} el
|
3515
|
+
* @return {?}
|
3516
|
+
*/
|
3517
|
+
InertBodyHelper.prototype.stripCustomNsAttrs = function (el) {
|
3518
|
+
var _this = this;
|
3519
|
+
this.DOM.attributeMap(el).forEach(function (_, attrName) {
|
3520
|
+
if (attrName === 'xmlns:ns1' || attrName.indexOf('ns1:') === 0) {
|
3521
|
+
_this.DOM.removeAttribute(el, attrName);
|
3522
|
+
}
|
3523
|
+
});
|
3524
|
+
for (var _i = 0, _a = this.DOM.childNodesAsList(el); _i < _a.length; _i++) {
|
3525
|
+
var n = _a[_i];
|
3526
|
+
if (this.DOM.isElementNode(n))
|
3527
|
+
this.stripCustomNsAttrs(/** @type {?} */ (n));
|
3528
|
+
}
|
3529
|
+
};
|
3530
|
+
return InertBodyHelper;
|
3531
|
+
}());
|
3532
|
+
/**
|
3533
|
+
* We need to determine whether the DOMParser exists in the global context.
|
3534
|
+
* The try-catch is because, on some browsers, trying to access this property
|
3535
|
+
* on window can actually throw an error.
|
3536
|
+
*
|
3537
|
+
* @suppress {uselessCode}
|
3538
|
+
* @return {?}
|
3539
|
+
*/
|
3540
|
+
function isDOMParserAvailable() {
|
3541
|
+
try {
|
3542
|
+
return !!((window)).DOMParser;
|
3543
|
+
}
|
3544
|
+
catch (e) {
|
3545
|
+
return false;
|
3546
|
+
}
|
3547
|
+
}
|
3384
3548
|
/**
|
3385
3549
|
* @license
|
3386
3550
|
* Copyright Google Inc. All Rights Reserved.
|
@@ -3447,38 +3611,6 @@ function sanitizeSrcset(srcset) {
|
|
3447
3611
|
* Use of this source code is governed by an MIT-style license that can be
|
3448
3612
|
* found in the LICENSE file at https://angular.io/license
|
3449
3613
|
*/
|
3450
|
-
/**
|
3451
|
-
* A <body> element that can be safely used to parse untrusted HTML. Lazily initialized below.
|
3452
|
-
*/
|
3453
|
-
var inertElement = null;
|
3454
|
-
/**
|
3455
|
-
* Lazily initialized to make sure the DOM adapter gets set before use.
|
3456
|
-
*/
|
3457
|
-
var DOM = null;
|
3458
|
-
/**
|
3459
|
-
* Returns an HTML element that is guaranteed to not execute code when creating elements in it.
|
3460
|
-
* @return {?}
|
3461
|
-
*/
|
3462
|
-
function getInertElement() {
|
3463
|
-
if (inertElement)
|
3464
|
-
return inertElement;
|
3465
|
-
DOM = getDOM();
|
3466
|
-
// Prefer using <template> element if supported.
|
3467
|
-
var /** @type {?} */ templateEl = DOM.createElement('template');
|
3468
|
-
if ('content' in templateEl)
|
3469
|
-
return templateEl;
|
3470
|
-
var /** @type {?} */ doc = DOM.createHtmlDocument();
|
3471
|
-
inertElement = DOM.querySelector(doc, 'body');
|
3472
|
-
if (inertElement == null) {
|
3473
|
-
// usually there should be only one body element in the document, but IE doesn't have any, so we
|
3474
|
-
// need to create one.
|
3475
|
-
var /** @type {?} */ html = DOM.createElement('html', doc);
|
3476
|
-
inertElement = DOM.createElement('body', doc);
|
3477
|
-
DOM.appendChild(html, inertElement);
|
3478
|
-
DOM.appendChild(doc, html);
|
3479
|
-
}
|
3480
|
-
return inertElement;
|
3481
|
-
}
|
3482
3614
|
/**
|
3483
3615
|
* @param {?} tags
|
3484
3616
|
* @return {?}
|
@@ -3554,6 +3686,7 @@ var SanitizingHtmlSerializer = (function () {
|
|
3554
3686
|
function SanitizingHtmlSerializer() {
|
3555
3687
|
this.sanitizedSomething = false;
|
3556
3688
|
this.buf = [];
|
3689
|
+
this.DOM = getDOM();
|
3557
3690
|
}
|
3558
3691
|
/**
|
3559
3692
|
* @param {?} el
|
@@ -3563,33 +3696,33 @@ var SanitizingHtmlSerializer = (function () {
|
|
3563
3696
|
// This cannot use a TreeWalker, as it has to run on Angular's various DOM adapters.
|
3564
3697
|
// However this code never accesses properties off of `document` before deleting its contents
|
3565
3698
|
// again, so it shouldn't be vulnerable to DOM clobbering.
|
3566
|
-
var /** @type {?} */ current = ((
|
3699
|
+
var /** @type {?} */ current = ((this.DOM.firstChild(el)));
|
3567
3700
|
while (current) {
|
3568
|
-
if (DOM.isElementNode(current)) {
|
3701
|
+
if (this.DOM.isElementNode(current)) {
|
3569
3702
|
this.startElement(/** @type {?} */ (current));
|
3570
3703
|
}
|
3571
|
-
else if (DOM.isTextNode(current)) {
|
3572
|
-
this.chars(/** @type {?} */ ((DOM.nodeValue(current))));
|
3704
|
+
else if (this.DOM.isTextNode(current)) {
|
3705
|
+
this.chars(/** @type {?} */ ((this.DOM.nodeValue(current))));
|
3573
3706
|
}
|
3574
3707
|
else {
|
3575
3708
|
// Strip non-element, non-text nodes.
|
3576
3709
|
this.sanitizedSomething = true;
|
3577
3710
|
}
|
3578
|
-
if (DOM.firstChild(current)) {
|
3579
|
-
current = ((DOM.firstChild(current)));
|
3711
|
+
if (this.DOM.firstChild(current)) {
|
3712
|
+
current = ((this.DOM.firstChild(current)));
|
3580
3713
|
continue;
|
3581
3714
|
}
|
3582
3715
|
while (current) {
|
3583
3716
|
// Leaving the element. Walk up and to the right, closing tags as we go.
|
3584
|
-
if (DOM.isElementNode(current)) {
|
3717
|
+
if (this.DOM.isElementNode(current)) {
|
3585
3718
|
this.endElement(/** @type {?} */ (current));
|
3586
3719
|
}
|
3587
|
-
var /** @type {?} */ next = checkClobberedElement(current, /** @type {?} */ ((DOM.nextSibling(current))));
|
3720
|
+
var /** @type {?} */ next = this.checkClobberedElement(current, /** @type {?} */ ((this.DOM.nextSibling(current))));
|
3588
3721
|
if (next) {
|
3589
3722
|
current = next;
|
3590
3723
|
break;
|
3591
3724
|
}
|
3592
|
-
current = checkClobberedElement(current, /** @type {?} */ ((DOM.parentElement(current))));
|
3725
|
+
current = this.checkClobberedElement(current, /** @type {?} */ ((this.DOM.parentElement(current))));
|
3593
3726
|
}
|
3594
3727
|
}
|
3595
3728
|
return this.buf.join('');
|
@@ -3600,14 +3733,14 @@ var SanitizingHtmlSerializer = (function () {
|
|
3600
3733
|
*/
|
3601
3734
|
SanitizingHtmlSerializer.prototype.startElement = function (element) {
|
3602
3735
|
var _this = this;
|
3603
|
-
var /** @type {?} */ tagName = DOM.nodeName(element).toLowerCase();
|
3736
|
+
var /** @type {?} */ tagName = this.DOM.nodeName(element).toLowerCase();
|
3604
3737
|
if (!VALID_ELEMENTS.hasOwnProperty(tagName)) {
|
3605
3738
|
this.sanitizedSomething = true;
|
3606
3739
|
return;
|
3607
3740
|
}
|
3608
3741
|
this.buf.push('<');
|
3609
3742
|
this.buf.push(tagName);
|
3610
|
-
DOM.attributeMap(element).forEach(function (value, attrName) {
|
3743
|
+
this.DOM.attributeMap(element).forEach(function (value, attrName) {
|
3611
3744
|
var /** @type {?} */ lower = attrName.toLowerCase();
|
3612
3745
|
if (!VALID_ATTRS.hasOwnProperty(lower)) {
|
3613
3746
|
_this.sanitizedSomething = true;
|
@@ -3631,7 +3764,7 @@ var SanitizingHtmlSerializer = (function () {
|
|
3631
3764
|
* @return {?}
|
3632
3765
|
*/
|
3633
3766
|
SanitizingHtmlSerializer.prototype.endElement = function (current) {
|
3634
|
-
var /** @type {?} */ tagName = DOM.nodeName(current).toLowerCase();
|
3767
|
+
var /** @type {?} */ tagName = this.DOM.nodeName(current).toLowerCase();
|
3635
3768
|
if (VALID_ELEMENTS.hasOwnProperty(tagName) && !VOID_ELEMENTS.hasOwnProperty(tagName)) {
|
3636
3769
|
this.buf.push('</');
|
3637
3770
|
this.buf.push(tagName);
|
@@ -3643,19 +3776,19 @@ var SanitizingHtmlSerializer = (function () {
|
|
3643
3776
|
* @return {?}
|
3644
3777
|
*/
|
3645
3778
|
SanitizingHtmlSerializer.prototype.chars = function (chars) { this.buf.push(encodeEntities(chars)); };
|
3779
|
+
/**
|
3780
|
+
* @param {?} node
|
3781
|
+
* @param {?} nextNode
|
3782
|
+
* @return {?}
|
3783
|
+
*/
|
3784
|
+
SanitizingHtmlSerializer.prototype.checkClobberedElement = function (node, nextNode) {
|
3785
|
+
if (nextNode && this.DOM.contains(node, nextNode)) {
|
3786
|
+
throw new Error("Failed to sanitize html because the element is clobbered: " + this.DOM.getOuterHTML(node));
|
3787
|
+
}
|
3788
|
+
return nextNode;
|
3789
|
+
};
|
3646
3790
|
return SanitizingHtmlSerializer;
|
3647
3791
|
}());
|
3648
|
-
/**
|
3649
|
-
* @param {?} node
|
3650
|
-
* @param {?} nextNode
|
3651
|
-
* @return {?}
|
3652
|
-
*/
|
3653
|
-
function checkClobberedElement(node, nextNode) {
|
3654
|
-
if (nextNode && DOM.contains(node, nextNode)) {
|
3655
|
-
throw new Error("Failed to sanitize html because the element is clobbered: " + DOM.getOuterHTML(node));
|
3656
|
-
}
|
3657
|
-
return nextNode;
|
3658
|
-
}
|
3659
3792
|
// Regular Expressions for parsing tags and attributes
|
3660
3793
|
var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
3661
3794
|
// ! to ~ is the ASCII range.
|
@@ -3678,27 +3811,7 @@ function encodeEntities(value) {
|
|
3678
3811
|
.replace(/</g, '<')
|
3679
3812
|
.replace(/>/g, '>');
|
3680
3813
|
}
|
3681
|
-
|
3682
|
-
* When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
|
3683
|
-
* attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g. 'ns1:xlink:foo').
|
3684
|
-
*
|
3685
|
-
* This is undesirable since we don't want to allow any of these custom attributes. This method
|
3686
|
-
* strips them all.
|
3687
|
-
* @param {?} el
|
3688
|
-
* @return {?}
|
3689
|
-
*/
|
3690
|
-
function stripCustomNsAttrs(el) {
|
3691
|
-
DOM.attributeMap(el).forEach(function (_, attrName) {
|
3692
|
-
if (attrName === 'xmlns:ns1' || attrName.indexOf('ns1:') === 0) {
|
3693
|
-
DOM.removeAttribute(el, attrName);
|
3694
|
-
}
|
3695
|
-
});
|
3696
|
-
for (var _i = 0, _a = DOM.childNodesAsList(el); _i < _a.length; _i++) {
|
3697
|
-
var n = _a[_i];
|
3698
|
-
if (DOM.isElementNode(n))
|
3699
|
-
stripCustomNsAttrs(/** @type {?} */ (n));
|
3700
|
-
}
|
3701
|
-
}
|
3814
|
+
var inertBodyHelper;
|
3702
3815
|
/**
|
3703
3816
|
* Sanitizes the given unsafe, untrusted HTML fragment, and returns HTML text that is safe to add to
|
3704
3817
|
* the DOM in a browser environment.
|
@@ -3707,10 +3820,13 @@ function stripCustomNsAttrs(el) {
|
|
3707
3820
|
* @return {?}
|
3708
3821
|
*/
|
3709
3822
|
function sanitizeHtml(defaultDoc, unsafeHtmlInput) {
|
3823
|
+
var /** @type {?} */ DOM = getDOM();
|
3824
|
+
var /** @type {?} */ inertBodyElement = null;
|
3710
3825
|
try {
|
3711
|
-
|
3826
|
+
inertBodyHelper = inertBodyHelper || new InertBodyHelper(defaultDoc, DOM);
|
3712
3827
|
// Make sure unsafeHtml is actually a string (TypeScript types are not enforced at runtime).
|
3713
3828
|
var /** @type {?} */ unsafeHtml = unsafeHtmlInput ? String(unsafeHtmlInput) : '';
|
3829
|
+
inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
|
3714
3830
|
// mXSS protection. Repeatedly parse the document to make sure it stabilizes, so that a browser
|
3715
3831
|
// trying to auto-correct incorrect HTML cannot cause formerly inert HTML to become dangerous.
|
3716
3832
|
var /** @type {?} */ mXSSAttempts = 5;
|
@@ -3721,30 +3837,25 @@ function sanitizeHtml(defaultDoc, unsafeHtmlInput) {
|
|
3721
3837
|
}
|
3722
3838
|
mXSSAttempts--;
|
3723
3839
|
unsafeHtml = parsedHtml;
|
3724
|
-
DOM.
|
3725
|
-
|
3726
|
-
// strip custom-namespaced attributes on IE<=11
|
3727
|
-
stripCustomNsAttrs(containerEl);
|
3728
|
-
}
|
3729
|
-
parsedHtml = DOM.getInnerHTML(containerEl);
|
3840
|
+
parsedHtml = DOM.getInnerHTML(inertBodyElement);
|
3841
|
+
inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
|
3730
3842
|
} while (unsafeHtml !== parsedHtml);
|
3731
3843
|
var /** @type {?} */ sanitizer = new SanitizingHtmlSerializer();
|
3732
|
-
var /** @type {?} */ safeHtml = sanitizer.sanitizeChildren(DOM.getTemplateContent(
|
3733
|
-
// Clear out the body element.
|
3734
|
-
var /** @type {?} */ parent = DOM.getTemplateContent(containerEl) || containerEl;
|
3735
|
-
for (var _i = 0, _a = DOM.childNodesAsList(parent); _i < _a.length; _i++) {
|
3736
|
-
var child = _a[_i];
|
3737
|
-
DOM.removeChild(parent, child);
|
3738
|
-
}
|
3844
|
+
var /** @type {?} */ safeHtml = sanitizer.sanitizeChildren(DOM.getTemplateContent(inertBodyElement) || inertBodyElement);
|
3739
3845
|
if (_angular_core.isDevMode() && sanitizer.sanitizedSomething) {
|
3740
3846
|
DOM.log('WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).');
|
3741
3847
|
}
|
3742
3848
|
return safeHtml;
|
3743
3849
|
}
|
3744
|
-
|
3850
|
+
finally {
|
3745
3851
|
// In case anything goes wrong, clear out inertElement to reset the entire DOM structure.
|
3746
|
-
|
3747
|
-
|
3852
|
+
if (inertBodyElement) {
|
3853
|
+
var /** @type {?} */ parent = DOM.getTemplateContent(inertBodyElement) || inertBodyElement;
|
3854
|
+
for (var _i = 0, _a = DOM.childNodesAsList(parent); _i < _a.length; _i++) {
|
3855
|
+
var child = _a[_i];
|
3856
|
+
DOM.removeChild(parent, child);
|
3857
|
+
}
|
3858
|
+
}
|
3748
3859
|
}
|
3749
3860
|
}
|
3750
3861
|
/**
|
@@ -4441,7 +4552,7 @@ var By = (function () {
|
|
4441
4552
|
/**
|
4442
4553
|
* \@stable
|
4443
4554
|
*/
|
4444
|
-
var VERSION = new _angular_core.Version('4.4.
|
4555
|
+
var VERSION = new _angular_core.Version('4.4.7');
|
4445
4556
|
|
4446
4557
|
exports.BrowserModule = BrowserModule;
|
4447
4558
|
exports.platformBrowser = platformBrowser;
|