@angular/platform-browser 4.4.6 → 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 -95
- package/@angular/platform-browser.es5.js.map +1 -1
- package/@angular/platform-browser.js +206 -92
- 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 +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.umd.js +211 -96
- package/bundles/platform-browser.umd.js.map +1 -1
- package/bundles/platform-browser.umd.min.js +11 -4
- 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
package/animations.d.ts
CHANGED
@@ -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
|
*/
|
@@ -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
|
*/
|
@@ -10,7 +10,7 @@
|
|
10
10
|
}(this, (function (exports,_angular_core,_angular_platformBrowser) { 'use strict';
|
11
11
|
|
12
12
|
/**
|
13
|
-
* @license Angular v4.4.
|
13
|
+
* @license Angular v4.4.7
|
14
14
|
* (c) 2010-2017 Google, Inc. https://angular.io/
|
15
15
|
* License: MIT
|
16
16
|
*/
|
@@ -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
|
*/
|
@@ -11,7 +11,7 @@
|
|
11
11
|
* found in the LICENSE file at https://angular.io/license
|
12
12
|
*/
|
13
13
|
function initBrowserTests(){_angular_platformBrowser.ɵBrowserDomAdapter.makeCurrent(),BrowserDetection.setup()}/**
|
14
|
-
* @license Angular v4.4.
|
14
|
+
* @license Angular v4.4.7
|
15
15
|
* (c) 2010-2017 Google, Inc. https://angular.io/
|
16
16
|
* License: MIT
|
17
17
|
*/
|
@@ -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
|
*/
|
@@ -3377,6 +3377,174 @@ KeyEventsPlugin.decorators = [
|
|
3377
3377
|
KeyEventsPlugin.ctorParameters = function () { return [
|
3378
3378
|
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [DOCUMENT$1,] },] },
|
3379
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
|
+
}
|
3380
3548
|
/**
|
3381
3549
|
* @license
|
3382
3550
|
* Copyright Google Inc. All Rights Reserved.
|
@@ -3443,38 +3611,6 @@ function sanitizeSrcset(srcset) {
|
|
3443
3611
|
* Use of this source code is governed by an MIT-style license that can be
|
3444
3612
|
* found in the LICENSE file at https://angular.io/license
|
3445
3613
|
*/
|
3446
|
-
/**
|
3447
|
-
* A <body> element that can be safely used to parse untrusted HTML. Lazily initialized below.
|
3448
|
-
*/
|
3449
|
-
var inertElement = null;
|
3450
|
-
/**
|
3451
|
-
* Lazily initialized to make sure the DOM adapter gets set before use.
|
3452
|
-
*/
|
3453
|
-
var DOM = null;
|
3454
|
-
/**
|
3455
|
-
* Returns an HTML element that is guaranteed to not execute code when creating elements in it.
|
3456
|
-
* @return {?}
|
3457
|
-
*/
|
3458
|
-
function getInertElement() {
|
3459
|
-
if (inertElement)
|
3460
|
-
return inertElement;
|
3461
|
-
DOM = getDOM();
|
3462
|
-
// Prefer using <template> element if supported.
|
3463
|
-
var /** @type {?} */ templateEl = DOM.createElement('template');
|
3464
|
-
if ('content' in templateEl)
|
3465
|
-
return templateEl;
|
3466
|
-
var /** @type {?} */ doc = DOM.createHtmlDocument();
|
3467
|
-
inertElement = DOM.querySelector(doc, 'body');
|
3468
|
-
if (inertElement == null) {
|
3469
|
-
// usually there should be only one body element in the document, but IE doesn't have any, so we
|
3470
|
-
// need to create one.
|
3471
|
-
var /** @type {?} */ html = DOM.createElement('html', doc);
|
3472
|
-
inertElement = DOM.createElement('body', doc);
|
3473
|
-
DOM.appendChild(html, inertElement);
|
3474
|
-
DOM.appendChild(doc, html);
|
3475
|
-
}
|
3476
|
-
return inertElement;
|
3477
|
-
}
|
3478
3614
|
/**
|
3479
3615
|
* @param {?} tags
|
3480
3616
|
* @return {?}
|
@@ -3550,6 +3686,7 @@ var SanitizingHtmlSerializer = (function () {
|
|
3550
3686
|
function SanitizingHtmlSerializer() {
|
3551
3687
|
this.sanitizedSomething = false;
|
3552
3688
|
this.buf = [];
|
3689
|
+
this.DOM = getDOM();
|
3553
3690
|
}
|
3554
3691
|
/**
|
3555
3692
|
* @param {?} el
|
@@ -3559,33 +3696,33 @@ var SanitizingHtmlSerializer = (function () {
|
|
3559
3696
|
// This cannot use a TreeWalker, as it has to run on Angular's various DOM adapters.
|
3560
3697
|
// However this code never accesses properties off of `document` before deleting its contents
|
3561
3698
|
// again, so it shouldn't be vulnerable to DOM clobbering.
|
3562
|
-
var /** @type {?} */ current = ((
|
3699
|
+
var /** @type {?} */ current = ((this.DOM.firstChild(el)));
|
3563
3700
|
while (current) {
|
3564
|
-
if (DOM.isElementNode(current)) {
|
3701
|
+
if (this.DOM.isElementNode(current)) {
|
3565
3702
|
this.startElement(/** @type {?} */ (current));
|
3566
3703
|
}
|
3567
|
-
else if (DOM.isTextNode(current)) {
|
3568
|
-
this.chars(/** @type {?} */ ((DOM.nodeValue(current))));
|
3704
|
+
else if (this.DOM.isTextNode(current)) {
|
3705
|
+
this.chars(/** @type {?} */ ((this.DOM.nodeValue(current))));
|
3569
3706
|
}
|
3570
3707
|
else {
|
3571
3708
|
// Strip non-element, non-text nodes.
|
3572
3709
|
this.sanitizedSomething = true;
|
3573
3710
|
}
|
3574
|
-
if (DOM.firstChild(current)) {
|
3575
|
-
current = ((DOM.firstChild(current)));
|
3711
|
+
if (this.DOM.firstChild(current)) {
|
3712
|
+
current = ((this.DOM.firstChild(current)));
|
3576
3713
|
continue;
|
3577
3714
|
}
|
3578
3715
|
while (current) {
|
3579
3716
|
// Leaving the element. Walk up and to the right, closing tags as we go.
|
3580
|
-
if (DOM.isElementNode(current)) {
|
3717
|
+
if (this.DOM.isElementNode(current)) {
|
3581
3718
|
this.endElement(/** @type {?} */ (current));
|
3582
3719
|
}
|
3583
|
-
var /** @type {?} */ next = checkClobberedElement(current, /** @type {?} */ ((DOM.nextSibling(current))));
|
3720
|
+
var /** @type {?} */ next = this.checkClobberedElement(current, /** @type {?} */ ((this.DOM.nextSibling(current))));
|
3584
3721
|
if (next) {
|
3585
3722
|
current = next;
|
3586
3723
|
break;
|
3587
3724
|
}
|
3588
|
-
current = checkClobberedElement(current, /** @type {?} */ ((DOM.parentElement(current))));
|
3725
|
+
current = this.checkClobberedElement(current, /** @type {?} */ ((this.DOM.parentElement(current))));
|
3589
3726
|
}
|
3590
3727
|
}
|
3591
3728
|
return this.buf.join('');
|
@@ -3596,14 +3733,14 @@ var SanitizingHtmlSerializer = (function () {
|
|
3596
3733
|
*/
|
3597
3734
|
SanitizingHtmlSerializer.prototype.startElement = function (element) {
|
3598
3735
|
var _this = this;
|
3599
|
-
var /** @type {?} */ tagName = DOM.nodeName(element).toLowerCase();
|
3736
|
+
var /** @type {?} */ tagName = this.DOM.nodeName(element).toLowerCase();
|
3600
3737
|
if (!VALID_ELEMENTS.hasOwnProperty(tagName)) {
|
3601
3738
|
this.sanitizedSomething = true;
|
3602
3739
|
return;
|
3603
3740
|
}
|
3604
3741
|
this.buf.push('<');
|
3605
3742
|
this.buf.push(tagName);
|
3606
|
-
DOM.attributeMap(element).forEach(function (value, attrName) {
|
3743
|
+
this.DOM.attributeMap(element).forEach(function (value, attrName) {
|
3607
3744
|
var /** @type {?} */ lower = attrName.toLowerCase();
|
3608
3745
|
if (!VALID_ATTRS.hasOwnProperty(lower)) {
|
3609
3746
|
_this.sanitizedSomething = true;
|
@@ -3627,7 +3764,7 @@ var SanitizingHtmlSerializer = (function () {
|
|
3627
3764
|
* @return {?}
|
3628
3765
|
*/
|
3629
3766
|
SanitizingHtmlSerializer.prototype.endElement = function (current) {
|
3630
|
-
var /** @type {?} */ tagName = DOM.nodeName(current).toLowerCase();
|
3767
|
+
var /** @type {?} */ tagName = this.DOM.nodeName(current).toLowerCase();
|
3631
3768
|
if (VALID_ELEMENTS.hasOwnProperty(tagName) && !VOID_ELEMENTS.hasOwnProperty(tagName)) {
|
3632
3769
|
this.buf.push('</');
|
3633
3770
|
this.buf.push(tagName);
|
@@ -3639,19 +3776,19 @@ var SanitizingHtmlSerializer = (function () {
|
|
3639
3776
|
* @return {?}
|
3640
3777
|
*/
|
3641
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
|
+
};
|
3642
3790
|
return SanitizingHtmlSerializer;
|
3643
3791
|
}());
|
3644
|
-
/**
|
3645
|
-
* @param {?} node
|
3646
|
-
* @param {?} nextNode
|
3647
|
-
* @return {?}
|
3648
|
-
*/
|
3649
|
-
function checkClobberedElement(node, nextNode) {
|
3650
|
-
if (nextNode && DOM.contains(node, nextNode)) {
|
3651
|
-
throw new Error("Failed to sanitize html because the element is clobbered: " + DOM.getOuterHTML(node));
|
3652
|
-
}
|
3653
|
-
return nextNode;
|
3654
|
-
}
|
3655
3792
|
// Regular Expressions for parsing tags and attributes
|
3656
3793
|
var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
3657
3794
|
// ! to ~ is the ASCII range.
|
@@ -3674,27 +3811,7 @@ function encodeEntities(value) {
|
|
3674
3811
|
.replace(/</g, '<')
|
3675
3812
|
.replace(/>/g, '>');
|
3676
3813
|
}
|
3677
|
-
|
3678
|
-
* When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
|
3679
|
-
* attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g. 'ns1:xlink:foo').
|
3680
|
-
*
|
3681
|
-
* This is undesirable since we don't want to allow any of these custom attributes. This method
|
3682
|
-
* strips them all.
|
3683
|
-
* @param {?} el
|
3684
|
-
* @return {?}
|
3685
|
-
*/
|
3686
|
-
function stripCustomNsAttrs(el) {
|
3687
|
-
DOM.attributeMap(el).forEach(function (_, attrName) {
|
3688
|
-
if (attrName === 'xmlns:ns1' || attrName.indexOf('ns1:') === 0) {
|
3689
|
-
DOM.removeAttribute(el, attrName);
|
3690
|
-
}
|
3691
|
-
});
|
3692
|
-
for (var _i = 0, _a = DOM.childNodesAsList(el); _i < _a.length; _i++) {
|
3693
|
-
var n = _a[_i];
|
3694
|
-
if (DOM.isElementNode(n))
|
3695
|
-
stripCustomNsAttrs(/** @type {?} */ (n));
|
3696
|
-
}
|
3697
|
-
}
|
3814
|
+
var inertBodyHelper;
|
3698
3815
|
/**
|
3699
3816
|
* Sanitizes the given unsafe, untrusted HTML fragment, and returns HTML text that is safe to add to
|
3700
3817
|
* the DOM in a browser environment.
|
@@ -3703,10 +3820,13 @@ function stripCustomNsAttrs(el) {
|
|
3703
3820
|
* @return {?}
|
3704
3821
|
*/
|
3705
3822
|
function sanitizeHtml(defaultDoc, unsafeHtmlInput) {
|
3823
|
+
var /** @type {?} */ DOM = getDOM();
|
3824
|
+
var /** @type {?} */ inertBodyElement = null;
|
3706
3825
|
try {
|
3707
|
-
|
3826
|
+
inertBodyHelper = inertBodyHelper || new InertBodyHelper(defaultDoc, DOM);
|
3708
3827
|
// Make sure unsafeHtml is actually a string (TypeScript types are not enforced at runtime).
|
3709
3828
|
var /** @type {?} */ unsafeHtml = unsafeHtmlInput ? String(unsafeHtmlInput) : '';
|
3829
|
+
inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
|
3710
3830
|
// mXSS protection. Repeatedly parse the document to make sure it stabilizes, so that a browser
|
3711
3831
|
// trying to auto-correct incorrect HTML cannot cause formerly inert HTML to become dangerous.
|
3712
3832
|
var /** @type {?} */ mXSSAttempts = 5;
|
@@ -3717,30 +3837,25 @@ function sanitizeHtml(defaultDoc, unsafeHtmlInput) {
|
|
3717
3837
|
}
|
3718
3838
|
mXSSAttempts--;
|
3719
3839
|
unsafeHtml = parsedHtml;
|
3720
|
-
DOM.
|
3721
|
-
|
3722
|
-
// strip custom-namespaced attributes on IE<=11
|
3723
|
-
stripCustomNsAttrs(containerEl);
|
3724
|
-
}
|
3725
|
-
parsedHtml = DOM.getInnerHTML(containerEl);
|
3840
|
+
parsedHtml = DOM.getInnerHTML(inertBodyElement);
|
3841
|
+
inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
|
3726
3842
|
} while (unsafeHtml !== parsedHtml);
|
3727
3843
|
var /** @type {?} */ sanitizer = new SanitizingHtmlSerializer();
|
3728
|
-
var /** @type {?} */ safeHtml = sanitizer.sanitizeChildren(DOM.getTemplateContent(
|
3729
|
-
// Clear out the body element.
|
3730
|
-
var /** @type {?} */ parent = DOM.getTemplateContent(containerEl) || containerEl;
|
3731
|
-
for (var _i = 0, _a = DOM.childNodesAsList(parent); _i < _a.length; _i++) {
|
3732
|
-
var child = _a[_i];
|
3733
|
-
DOM.removeChild(parent, child);
|
3734
|
-
}
|
3844
|
+
var /** @type {?} */ safeHtml = sanitizer.sanitizeChildren(DOM.getTemplateContent(inertBodyElement) || inertBodyElement);
|
3735
3845
|
if (_angular_core.isDevMode() && sanitizer.sanitizedSomething) {
|
3736
3846
|
DOM.log('WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).');
|
3737
3847
|
}
|
3738
3848
|
return safeHtml;
|
3739
3849
|
}
|
3740
|
-
|
3850
|
+
finally {
|
3741
3851
|
// In case anything goes wrong, clear out inertElement to reset the entire DOM structure.
|
3742
|
-
|
3743
|
-
|
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
|
+
}
|
3744
3859
|
}
|
3745
3860
|
}
|
3746
3861
|
/**
|
@@ -4437,7 +4552,7 @@ var By = (function () {
|
|
4437
4552
|
/**
|
4438
4553
|
* \@stable
|
4439
4554
|
*/
|
4440
|
-
var VERSION = new _angular_core.Version('4.4.
|
4555
|
+
var VERSION = new _angular_core.Version('4.4.7');
|
4441
4556
|
|
4442
4557
|
exports.BrowserModule = BrowserModule;
|
4443
4558
|
exports.platformBrowser = platformBrowser;
|