@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,6 +1,6 @@
|
|
1
1
|
import * as tslib_1 from "tslib";
|
2
2
|
/**
|
3
|
-
* @license Angular v4.4.
|
3
|
+
* @license Angular v4.4.7
|
4
4
|
* (c) 2010-2017 Google, Inc. https://angular.io/
|
5
5
|
* License: MIT
|
6
6
|
*/
|
@@ -112,8 +112,6 @@ var DomAdapter = (function () {
|
|
112
112
|
enumerable: true,
|
113
113
|
configurable: true
|
114
114
|
});
|
115
|
-
;
|
116
|
-
;
|
117
115
|
/**
|
118
116
|
* @abstract
|
119
117
|
* @param {?} nodeA
|
@@ -2479,7 +2477,6 @@ var EventManagerPlugin = (function () {
|
|
2479
2477
|
}
|
2480
2478
|
return this.addEventListener(target, eventName, handler);
|
2481
2479
|
};
|
2482
|
-
;
|
2483
2480
|
return EventManagerPlugin;
|
2484
2481
|
}());
|
2485
2482
|
/**
|
@@ -2667,7 +2664,6 @@ var DomRendererFactory2 = (function () {
|
|
2667
2664
|
this.rendererByCompId = new Map();
|
2668
2665
|
this.defaultRenderer = new DefaultDomRenderer2(eventManager);
|
2669
2666
|
}
|
2670
|
-
;
|
2671
2667
|
/**
|
2672
2668
|
* @param {?} element
|
2673
2669
|
* @param {?} type
|
@@ -3347,6 +3343,174 @@ KeyEventsPlugin.decorators = [
|
|
3347
3343
|
KeyEventsPlugin.ctorParameters = function () { return [
|
3348
3344
|
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
|
3349
3345
|
]; };
|
3346
|
+
/**
|
3347
|
+
* @license
|
3348
|
+
* Copyright Google Inc. All Rights Reserved.
|
3349
|
+
*
|
3350
|
+
* Use of this source code is governed by an MIT-style license that can be
|
3351
|
+
* found in the LICENSE file at https://angular.io/license
|
3352
|
+
*/
|
3353
|
+
/**
|
3354
|
+
* This helper class is used to get hold of an inert tree of DOM elements containing dirty HTML
|
3355
|
+
* that needs sanitizing.
|
3356
|
+
* Depending upon browser support we must use one of three strategies for doing this.
|
3357
|
+
* Support: Safari 10.x -> XHR strategy
|
3358
|
+
* Support: Firefox -> DomParser strategy
|
3359
|
+
* Default: InertDocument strategy
|
3360
|
+
*/
|
3361
|
+
var InertBodyHelper = (function () {
|
3362
|
+
/**
|
3363
|
+
* @param {?} defaultDoc
|
3364
|
+
* @param {?} DOM
|
3365
|
+
*/
|
3366
|
+
function InertBodyHelper(defaultDoc, DOM) {
|
3367
|
+
this.defaultDoc = defaultDoc;
|
3368
|
+
this.DOM = DOM;
|
3369
|
+
var inertDocument = this.DOM.createHtmlDocument();
|
3370
|
+
this.inertBodyElement = inertDocument.body;
|
3371
|
+
if (this.inertBodyElement == null) {
|
3372
|
+
// usually there should be only one body element in the document, but IE doesn't have any, so
|
3373
|
+
// we need to create one.
|
3374
|
+
var inertHtml = this.DOM.createElement('html', inertDocument);
|
3375
|
+
this.inertBodyElement = this.DOM.createElement('body', inertDocument);
|
3376
|
+
this.DOM.appendChild(inertHtml, this.inertBodyElement);
|
3377
|
+
this.DOM.appendChild(inertDocument, inertHtml);
|
3378
|
+
}
|
3379
|
+
this.DOM.setInnerHTML(this.inertBodyElement, '<svg><g onload="this.parentNode.remove()"></g></svg>');
|
3380
|
+
if (this.inertBodyElement.querySelector && !this.inertBodyElement.querySelector('svg')) {
|
3381
|
+
// We just hit the Safari 10.1 bug - which allows JS to run inside the SVG G element
|
3382
|
+
// so use the XHR strategy.
|
3383
|
+
this.getInertBodyElement = this.getInertBodyElement_XHR;
|
3384
|
+
return;
|
3385
|
+
}
|
3386
|
+
this.DOM.setInnerHTML(this.inertBodyElement, '<svg><p><style><img src="</style><img src=x onerror=alert(1)//">');
|
3387
|
+
if (this.inertBodyElement.querySelector && this.inertBodyElement.querySelector('svg img')) {
|
3388
|
+
// We just hit the Firefox bug - which prevents the inner img JS from being sanitized
|
3389
|
+
// so use the DOMParser strategy, if it is available.
|
3390
|
+
// If the DOMParser is not available then we are not in Firefox (Server/WebWorker?) so we
|
3391
|
+
// fall through to the default strategy below.
|
3392
|
+
if (isDOMParserAvailable()) {
|
3393
|
+
this.getInertBodyElement = this.getInertBodyElement_DOMParser;
|
3394
|
+
return;
|
3395
|
+
}
|
3396
|
+
}
|
3397
|
+
// None of the bugs were hit so it is safe for us to use the default InertDocument strategy
|
3398
|
+
this.getInertBodyElement = this.getInertBodyElement_InertDocument;
|
3399
|
+
}
|
3400
|
+
/**
|
3401
|
+
* Use XHR to create and fill an inert body element (on Safari 10.1)
|
3402
|
+
* See
|
3403
|
+
* https://github.com/cure53/DOMPurify/blob/a992d3a75031cb8bb032e5ea8399ba972bdf9a65/src/purify.js#L439-L449
|
3404
|
+
* @param {?} html
|
3405
|
+
* @return {?}
|
3406
|
+
*/
|
3407
|
+
InertBodyHelper.prototype.getInertBodyElement_XHR = function (html) {
|
3408
|
+
// We add these extra elements to ensure that the rest of the content is parsed as expected
|
3409
|
+
// e.g. leading whitespace is maintained and tags like `<meta>` do not get hoisted to the
|
3410
|
+
// `<head>` tag.
|
3411
|
+
html = '<body><remove></remove>' + html + '</body>';
|
3412
|
+
try {
|
3413
|
+
html = encodeURI(html);
|
3414
|
+
}
|
3415
|
+
catch (e) {
|
3416
|
+
return null;
|
3417
|
+
}
|
3418
|
+
var /** @type {?} */ xhr = new XMLHttpRequest();
|
3419
|
+
xhr.responseType = 'document';
|
3420
|
+
xhr.open('GET', 'data:text/html;charset=utf-8,' + html, false);
|
3421
|
+
xhr.send(null);
|
3422
|
+
var /** @type {?} */ body = xhr.response.body;
|
3423
|
+
body.removeChild(/** @type {?} */ ((body.firstChild)));
|
3424
|
+
return body;
|
3425
|
+
};
|
3426
|
+
/**
|
3427
|
+
* Use DOMParser to create and fill an inert body element (on Firefox)
|
3428
|
+
* See https://github.com/cure53/DOMPurify/releases/tag/0.6.7
|
3429
|
+
*
|
3430
|
+
* @param {?} html
|
3431
|
+
* @return {?}
|
3432
|
+
*/
|
3433
|
+
InertBodyHelper.prototype.getInertBodyElement_DOMParser = function (html) {
|
3434
|
+
// We add these extra elements to ensure that the rest of the content is parsed as expected
|
3435
|
+
// e.g. leading whitespace is maintained and tags like `<meta>` do not get hoisted to the
|
3436
|
+
// `<head>` tag.
|
3437
|
+
html = '<body><remove></remove>' + html + '</body>';
|
3438
|
+
try {
|
3439
|
+
var /** @type {?} */ body = (new ((window))
|
3440
|
+
.DOMParser()
|
3441
|
+
.parseFromString(html, 'text/html')
|
3442
|
+
.body);
|
3443
|
+
body.removeChild(/** @type {?} */ ((body.firstChild)));
|
3444
|
+
return body;
|
3445
|
+
}
|
3446
|
+
catch (e) {
|
3447
|
+
return null;
|
3448
|
+
}
|
3449
|
+
};
|
3450
|
+
/**
|
3451
|
+
* Use an HTML5 `template` element, if supported, or an inert body element created via
|
3452
|
+
* `createHtmlDocument` to create and fill an inert DOM element.
|
3453
|
+
* This is the default sane strategy to use if the browser does not require one of the specialised
|
3454
|
+
* strategies above.
|
3455
|
+
* @param {?} html
|
3456
|
+
* @return {?}
|
3457
|
+
*/
|
3458
|
+
InertBodyHelper.prototype.getInertBodyElement_InertDocument = function (html) {
|
3459
|
+
// Prefer using <template> element if supported.
|
3460
|
+
var /** @type {?} */ templateEl = this.DOM.createElement('template');
|
3461
|
+
if ('content' in templateEl) {
|
3462
|
+
this.DOM.setInnerHTML(templateEl, html);
|
3463
|
+
return templateEl;
|
3464
|
+
}
|
3465
|
+
this.DOM.setInnerHTML(this.inertBodyElement, html);
|
3466
|
+
// Support: IE 9-11 only
|
3467
|
+
// strip custom-namespaced attributes on IE<=11
|
3468
|
+
if (this.defaultDoc.documentMode) {
|
3469
|
+
this.stripCustomNsAttrs(this.inertBodyElement);
|
3470
|
+
}
|
3471
|
+
return this.inertBodyElement;
|
3472
|
+
};
|
3473
|
+
/**
|
3474
|
+
* When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
|
3475
|
+
* attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g.
|
3476
|
+
* 'ns1:xlink:foo').
|
3477
|
+
*
|
3478
|
+
* This is undesirable since we don't want to allow any of these custom attributes. This method
|
3479
|
+
* strips them all.
|
3480
|
+
* @param {?} el
|
3481
|
+
* @return {?}
|
3482
|
+
*/
|
3483
|
+
InertBodyHelper.prototype.stripCustomNsAttrs = function (el) {
|
3484
|
+
var _this = this;
|
3485
|
+
this.DOM.attributeMap(el).forEach(function (_, attrName) {
|
3486
|
+
if (attrName === 'xmlns:ns1' || attrName.indexOf('ns1:') === 0) {
|
3487
|
+
_this.DOM.removeAttribute(el, attrName);
|
3488
|
+
}
|
3489
|
+
});
|
3490
|
+
for (var _i = 0, _a = this.DOM.childNodesAsList(el); _i < _a.length; _i++) {
|
3491
|
+
var n = _a[_i];
|
3492
|
+
if (this.DOM.isElementNode(n))
|
3493
|
+
this.stripCustomNsAttrs(/** @type {?} */ (n));
|
3494
|
+
}
|
3495
|
+
};
|
3496
|
+
return InertBodyHelper;
|
3497
|
+
}());
|
3498
|
+
/**
|
3499
|
+
* We need to determine whether the DOMParser exists in the global context.
|
3500
|
+
* The try-catch is because, on some browsers, trying to access this property
|
3501
|
+
* on window can actually throw an error.
|
3502
|
+
*
|
3503
|
+
* @suppress {uselessCode}
|
3504
|
+
* @return {?}
|
3505
|
+
*/
|
3506
|
+
function isDOMParserAvailable() {
|
3507
|
+
try {
|
3508
|
+
return !!((window)).DOMParser;
|
3509
|
+
}
|
3510
|
+
catch (e) {
|
3511
|
+
return false;
|
3512
|
+
}
|
3513
|
+
}
|
3350
3514
|
/**
|
3351
3515
|
* @license
|
3352
3516
|
* Copyright Google Inc. All Rights Reserved.
|
@@ -3413,38 +3577,6 @@ function sanitizeSrcset(srcset) {
|
|
3413
3577
|
* Use of this source code is governed by an MIT-style license that can be
|
3414
3578
|
* found in the LICENSE file at https://angular.io/license
|
3415
3579
|
*/
|
3416
|
-
/**
|
3417
|
-
* A <body> element that can be safely used to parse untrusted HTML. Lazily initialized below.
|
3418
|
-
*/
|
3419
|
-
var inertElement = null;
|
3420
|
-
/**
|
3421
|
-
* Lazily initialized to make sure the DOM adapter gets set before use.
|
3422
|
-
*/
|
3423
|
-
var DOM = null;
|
3424
|
-
/**
|
3425
|
-
* Returns an HTML element that is guaranteed to not execute code when creating elements in it.
|
3426
|
-
* @return {?}
|
3427
|
-
*/
|
3428
|
-
function getInertElement() {
|
3429
|
-
if (inertElement)
|
3430
|
-
return inertElement;
|
3431
|
-
DOM = getDOM();
|
3432
|
-
// Prefer using <template> element if supported.
|
3433
|
-
var /** @type {?} */ templateEl = DOM.createElement('template');
|
3434
|
-
if ('content' in templateEl)
|
3435
|
-
return templateEl;
|
3436
|
-
var /** @type {?} */ doc = DOM.createHtmlDocument();
|
3437
|
-
inertElement = DOM.querySelector(doc, 'body');
|
3438
|
-
if (inertElement == null) {
|
3439
|
-
// usually there should be only one body element in the document, but IE doesn't have any, so we
|
3440
|
-
// need to create one.
|
3441
|
-
var /** @type {?} */ html = DOM.createElement('html', doc);
|
3442
|
-
inertElement = DOM.createElement('body', doc);
|
3443
|
-
DOM.appendChild(html, inertElement);
|
3444
|
-
DOM.appendChild(doc, html);
|
3445
|
-
}
|
3446
|
-
return inertElement;
|
3447
|
-
}
|
3448
3580
|
/**
|
3449
3581
|
* @param {?} tags
|
3450
3582
|
* @return {?}
|
@@ -3520,6 +3652,7 @@ var SanitizingHtmlSerializer = (function () {
|
|
3520
3652
|
function SanitizingHtmlSerializer() {
|
3521
3653
|
this.sanitizedSomething = false;
|
3522
3654
|
this.buf = [];
|
3655
|
+
this.DOM = getDOM();
|
3523
3656
|
}
|
3524
3657
|
/**
|
3525
3658
|
* @param {?} el
|
@@ -3529,33 +3662,33 @@ var SanitizingHtmlSerializer = (function () {
|
|
3529
3662
|
// This cannot use a TreeWalker, as it has to run on Angular's various DOM adapters.
|
3530
3663
|
// However this code never accesses properties off of `document` before deleting its contents
|
3531
3664
|
// again, so it shouldn't be vulnerable to DOM clobbering.
|
3532
|
-
var /** @type {?} */ current = ((
|
3665
|
+
var /** @type {?} */ current = ((this.DOM.firstChild(el)));
|
3533
3666
|
while (current) {
|
3534
|
-
if (DOM.isElementNode(current)) {
|
3667
|
+
if (this.DOM.isElementNode(current)) {
|
3535
3668
|
this.startElement(/** @type {?} */ (current));
|
3536
3669
|
}
|
3537
|
-
else if (DOM.isTextNode(current)) {
|
3538
|
-
this.chars(/** @type {?} */ ((DOM.nodeValue(current))));
|
3670
|
+
else if (this.DOM.isTextNode(current)) {
|
3671
|
+
this.chars(/** @type {?} */ ((this.DOM.nodeValue(current))));
|
3539
3672
|
}
|
3540
3673
|
else {
|
3541
3674
|
// Strip non-element, non-text nodes.
|
3542
3675
|
this.sanitizedSomething = true;
|
3543
3676
|
}
|
3544
|
-
if (DOM.firstChild(current)) {
|
3545
|
-
current = ((DOM.firstChild(current)));
|
3677
|
+
if (this.DOM.firstChild(current)) {
|
3678
|
+
current = ((this.DOM.firstChild(current)));
|
3546
3679
|
continue;
|
3547
3680
|
}
|
3548
3681
|
while (current) {
|
3549
3682
|
// Leaving the element. Walk up and to the right, closing tags as we go.
|
3550
|
-
if (DOM.isElementNode(current)) {
|
3683
|
+
if (this.DOM.isElementNode(current)) {
|
3551
3684
|
this.endElement(/** @type {?} */ (current));
|
3552
3685
|
}
|
3553
|
-
var /** @type {?} */ next = checkClobberedElement(current, /** @type {?} */ ((DOM.nextSibling(current))));
|
3686
|
+
var /** @type {?} */ next = this.checkClobberedElement(current, /** @type {?} */ ((this.DOM.nextSibling(current))));
|
3554
3687
|
if (next) {
|
3555
3688
|
current = next;
|
3556
3689
|
break;
|
3557
3690
|
}
|
3558
|
-
current = checkClobberedElement(current, /** @type {?} */ ((DOM.parentElement(current))));
|
3691
|
+
current = this.checkClobberedElement(current, /** @type {?} */ ((this.DOM.parentElement(current))));
|
3559
3692
|
}
|
3560
3693
|
}
|
3561
3694
|
return this.buf.join('');
|
@@ -3566,14 +3699,14 @@ var SanitizingHtmlSerializer = (function () {
|
|
3566
3699
|
*/
|
3567
3700
|
SanitizingHtmlSerializer.prototype.startElement = function (element) {
|
3568
3701
|
var _this = this;
|
3569
|
-
var /** @type {?} */ tagName = DOM.nodeName(element).toLowerCase();
|
3702
|
+
var /** @type {?} */ tagName = this.DOM.nodeName(element).toLowerCase();
|
3570
3703
|
if (!VALID_ELEMENTS.hasOwnProperty(tagName)) {
|
3571
3704
|
this.sanitizedSomething = true;
|
3572
3705
|
return;
|
3573
3706
|
}
|
3574
3707
|
this.buf.push('<');
|
3575
3708
|
this.buf.push(tagName);
|
3576
|
-
DOM.attributeMap(element).forEach(function (value, attrName) {
|
3709
|
+
this.DOM.attributeMap(element).forEach(function (value, attrName) {
|
3577
3710
|
var /** @type {?} */ lower = attrName.toLowerCase();
|
3578
3711
|
if (!VALID_ATTRS.hasOwnProperty(lower)) {
|
3579
3712
|
_this.sanitizedSomething = true;
|
@@ -3597,7 +3730,7 @@ var SanitizingHtmlSerializer = (function () {
|
|
3597
3730
|
* @return {?}
|
3598
3731
|
*/
|
3599
3732
|
SanitizingHtmlSerializer.prototype.endElement = function (current) {
|
3600
|
-
var /** @type {?} */ tagName = DOM.nodeName(current).toLowerCase();
|
3733
|
+
var /** @type {?} */ tagName = this.DOM.nodeName(current).toLowerCase();
|
3601
3734
|
if (VALID_ELEMENTS.hasOwnProperty(tagName) && !VOID_ELEMENTS.hasOwnProperty(tagName)) {
|
3602
3735
|
this.buf.push('</');
|
3603
3736
|
this.buf.push(tagName);
|
@@ -3609,19 +3742,19 @@ var SanitizingHtmlSerializer = (function () {
|
|
3609
3742
|
* @return {?}
|
3610
3743
|
*/
|
3611
3744
|
SanitizingHtmlSerializer.prototype.chars = function (chars) { this.buf.push(encodeEntities(chars)); };
|
3745
|
+
/**
|
3746
|
+
* @param {?} node
|
3747
|
+
* @param {?} nextNode
|
3748
|
+
* @return {?}
|
3749
|
+
*/
|
3750
|
+
SanitizingHtmlSerializer.prototype.checkClobberedElement = function (node, nextNode) {
|
3751
|
+
if (nextNode && this.DOM.contains(node, nextNode)) {
|
3752
|
+
throw new Error("Failed to sanitize html because the element is clobbered: " + this.DOM.getOuterHTML(node));
|
3753
|
+
}
|
3754
|
+
return nextNode;
|
3755
|
+
};
|
3612
3756
|
return SanitizingHtmlSerializer;
|
3613
3757
|
}());
|
3614
|
-
/**
|
3615
|
-
* @param {?} node
|
3616
|
-
* @param {?} nextNode
|
3617
|
-
* @return {?}
|
3618
|
-
*/
|
3619
|
-
function checkClobberedElement(node, nextNode) {
|
3620
|
-
if (nextNode && DOM.contains(node, nextNode)) {
|
3621
|
-
throw new Error("Failed to sanitize html because the element is clobbered: " + DOM.getOuterHTML(node));
|
3622
|
-
}
|
3623
|
-
return nextNode;
|
3624
|
-
}
|
3625
3758
|
// Regular Expressions for parsing tags and attributes
|
3626
3759
|
var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
3627
3760
|
// ! to ~ is the ASCII range.
|
@@ -3644,27 +3777,7 @@ function encodeEntities(value) {
|
|
3644
3777
|
.replace(/</g, '<')
|
3645
3778
|
.replace(/>/g, '>');
|
3646
3779
|
}
|
3647
|
-
|
3648
|
-
* When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
|
3649
|
-
* attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g. 'ns1:xlink:foo').
|
3650
|
-
*
|
3651
|
-
* This is undesirable since we don't want to allow any of these custom attributes. This method
|
3652
|
-
* strips them all.
|
3653
|
-
* @param {?} el
|
3654
|
-
* @return {?}
|
3655
|
-
*/
|
3656
|
-
function stripCustomNsAttrs(el) {
|
3657
|
-
DOM.attributeMap(el).forEach(function (_, attrName) {
|
3658
|
-
if (attrName === 'xmlns:ns1' || attrName.indexOf('ns1:') === 0) {
|
3659
|
-
DOM.removeAttribute(el, attrName);
|
3660
|
-
}
|
3661
|
-
});
|
3662
|
-
for (var _i = 0, _a = DOM.childNodesAsList(el); _i < _a.length; _i++) {
|
3663
|
-
var n = _a[_i];
|
3664
|
-
if (DOM.isElementNode(n))
|
3665
|
-
stripCustomNsAttrs(/** @type {?} */ (n));
|
3666
|
-
}
|
3667
|
-
}
|
3780
|
+
var inertBodyHelper;
|
3668
3781
|
/**
|
3669
3782
|
* Sanitizes the given unsafe, untrusted HTML fragment, and returns HTML text that is safe to add to
|
3670
3783
|
* the DOM in a browser environment.
|
@@ -3673,10 +3786,13 @@ function stripCustomNsAttrs(el) {
|
|
3673
3786
|
* @return {?}
|
3674
3787
|
*/
|
3675
3788
|
function sanitizeHtml(defaultDoc, unsafeHtmlInput) {
|
3789
|
+
var /** @type {?} */ DOM = getDOM();
|
3790
|
+
var /** @type {?} */ inertBodyElement = null;
|
3676
3791
|
try {
|
3677
|
-
|
3792
|
+
inertBodyHelper = inertBodyHelper || new InertBodyHelper(defaultDoc, DOM);
|
3678
3793
|
// Make sure unsafeHtml is actually a string (TypeScript types are not enforced at runtime).
|
3679
3794
|
var /** @type {?} */ unsafeHtml = unsafeHtmlInput ? String(unsafeHtmlInput) : '';
|
3795
|
+
inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
|
3680
3796
|
// mXSS protection. Repeatedly parse the document to make sure it stabilizes, so that a browser
|
3681
3797
|
// trying to auto-correct incorrect HTML cannot cause formerly inert HTML to become dangerous.
|
3682
3798
|
var /** @type {?} */ mXSSAttempts = 5;
|
@@ -3687,30 +3803,25 @@ function sanitizeHtml(defaultDoc, unsafeHtmlInput) {
|
|
3687
3803
|
}
|
3688
3804
|
mXSSAttempts--;
|
3689
3805
|
unsafeHtml = parsedHtml;
|
3690
|
-
DOM.
|
3691
|
-
|
3692
|
-
// strip custom-namespaced attributes on IE<=11
|
3693
|
-
stripCustomNsAttrs(containerEl);
|
3694
|
-
}
|
3695
|
-
parsedHtml = DOM.getInnerHTML(containerEl);
|
3806
|
+
parsedHtml = DOM.getInnerHTML(inertBodyElement);
|
3807
|
+
inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
|
3696
3808
|
} while (unsafeHtml !== parsedHtml);
|
3697
3809
|
var /** @type {?} */ sanitizer = new SanitizingHtmlSerializer();
|
3698
|
-
var /** @type {?} */ safeHtml = sanitizer.sanitizeChildren(DOM.getTemplateContent(
|
3699
|
-
// Clear out the body element.
|
3700
|
-
var /** @type {?} */ parent = DOM.getTemplateContent(containerEl) || containerEl;
|
3701
|
-
for (var _i = 0, _a = DOM.childNodesAsList(parent); _i < _a.length; _i++) {
|
3702
|
-
var child = _a[_i];
|
3703
|
-
DOM.removeChild(parent, child);
|
3704
|
-
}
|
3810
|
+
var /** @type {?} */ safeHtml = sanitizer.sanitizeChildren(DOM.getTemplateContent(inertBodyElement) || inertBodyElement);
|
3705
3811
|
if (isDevMode() && sanitizer.sanitizedSomething) {
|
3706
3812
|
DOM.log('WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).');
|
3707
3813
|
}
|
3708
3814
|
return safeHtml;
|
3709
3815
|
}
|
3710
|
-
|
3816
|
+
finally {
|
3711
3817
|
// In case anything goes wrong, clear out inertElement to reset the entire DOM structure.
|
3712
|
-
|
3713
|
-
|
3818
|
+
if (inertBodyElement) {
|
3819
|
+
var /** @type {?} */ parent = DOM.getTemplateContent(inertBodyElement) || inertBodyElement;
|
3820
|
+
for (var _i = 0, _a = DOM.childNodesAsList(parent); _i < _a.length; _i++) {
|
3821
|
+
var child = _a[_i];
|
3822
|
+
DOM.removeChild(parent, child);
|
3823
|
+
}
|
3824
|
+
}
|
3714
3825
|
}
|
3715
3826
|
}
|
3716
3827
|
/**
|
@@ -4407,7 +4518,7 @@ var By = (function () {
|
|
4407
4518
|
/**
|
4408
4519
|
* \@stable
|
4409
4520
|
*/
|
4410
|
-
var VERSION = new Version('4.4.
|
4521
|
+
var VERSION = new Version('4.4.7');
|
4411
4522
|
/**
|
4412
4523
|
* @license
|
4413
4524
|
* Copyright Google Inc. All Rights Reserved.
|