@angular/core 10.2.3 → 10.2.4

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v10.2.3
2
+ * @license Angular v10.2.4
3
3
  * (c) 2010-2020 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -5014,6 +5014,11 @@
5014
5014
  if (_runModeLocked) {
5015
5015
  throw new Error('Cannot enable prod mode after platform setup.');
5016
5016
  }
5017
+ // The below check is there so when ngDevMode is set via terser
5018
+ // `global['ngDevMode'] = false;` is also dropped.
5019
+ if (typeof ngDevMode === undefined || !!ngDevMode) {
5020
+ _global['ngDevMode'] = false;
5021
+ }
5017
5022
  _devMode = false;
5018
5023
  }
5019
5024
 
@@ -5658,6 +5663,42 @@
5658
5663
  return lView && lView[SANITIZER];
5659
5664
  }
5660
5665
 
5666
+ /**
5667
+ * @license
5668
+ * Copyright Google LLC All Rights Reserved.
5669
+ *
5670
+ * Use of this source code is governed by an MIT-style license that can be
5671
+ * found in the LICENSE file at https://angular.io/license
5672
+ */
5673
+ var END_COMMENT = /-->/g;
5674
+ var END_COMMENT_ESCAPED = '-\u200B-\u200B>';
5675
+ /**
5676
+ * Escape the content of the strings so that it can be safely inserted into a comment node.
5677
+ *
5678
+ * The issue is that HTML does not specify any way to escape comment end text inside the comment.
5679
+ * `<!-- The way you close a comment is with "-->". -->`. Above the `"-->"` is meant to be text not
5680
+ * an end to the comment. This can be created programmatically through DOM APIs.
5681
+ *
5682
+ * ```
5683
+ * div.innerHTML = div.innerHTML
5684
+ * ```
5685
+ *
5686
+ * One would expect that the above code would be safe to do, but it turns out that because comment
5687
+ * text is not escaped, the comment may contain text which will prematurely close the comment
5688
+ * opening up the application for XSS attack. (In SSR we programmatically create comment nodes which
5689
+ * may contain such text and expect them to be safe.)
5690
+ *
5691
+ * This function escapes the comment text by looking for the closing char sequence `-->` and replace
5692
+ * it with `-_-_>` where the `_` is a zero width space `\u200B`. The result is that if a comment
5693
+ * contains `-->` text it will render normally but it will not cause the HTML parser to close the
5694
+ * comment.
5695
+ *
5696
+ * @param value text to make safe for comment node by escaping the comment close character sequence
5697
+ */
5698
+ function escapeCommentText(value) {
5699
+ return value.replace(END_COMMENT, END_COMMENT_ESCAPED);
5700
+ }
5701
+
5661
5702
  /**
5662
5703
  * @license
5663
5704
  * Copyright Google LLC All Rights Reserved.
@@ -8400,7 +8441,7 @@
8400
8441
  }
8401
8442
  }
8402
8443
  else {
8403
- var textContent = "bindings=" + JSON.stringify((_a = {}, _a[attrName] = debugValue, _a), null, 2);
8444
+ var textContent = escapeCommentText("bindings=" + JSON.stringify((_a = {}, _a[attrName] = debugValue, _a), null, 2));
8404
8445
  if (isProceduralRenderer(renderer)) {
8405
8446
  renderer.setValue(element, textContent);
8406
8447
  }
@@ -21686,7 +21727,7 @@
21686
21727
  /**
21687
21728
  * @publicApi
21688
21729
  */
21689
- var VERSION = new Version('10.2.3');
21730
+ var VERSION = new Version('10.2.4');
21690
21731
 
21691
21732
  /**
21692
21733
  * @license
@@ -32163,7 +32204,7 @@
32163
32204
  var el = asElementData(view, elDef.nodeIndex).renderElement;
32164
32205
  if (!elDef.element.name) {
32165
32206
  // a comment.
32166
- view.renderer.setValue(el, "bindings=" + JSON.stringify(bindingValues, null, 2));
32207
+ view.renderer.setValue(el, escapeCommentText("bindings=" + JSON.stringify(bindingValues, null, 2)));
32167
32208
  }
32168
32209
  else {
32169
32210
  // a regular element.
@@ -32452,7 +32493,7 @@
32452
32493
  return el;
32453
32494
  };
32454
32495
  DebugRenderer2.prototype.createComment = function (value) {
32455
- var comment = this.delegate.createComment(value);
32496
+ var comment = this.delegate.createComment(escapeCommentText(value));
32456
32497
  var debugCtx = this.createDebugContext(comment);
32457
32498
  if (debugCtx) {
32458
32499
  indexDebugNode(new DebugNode__PRE_R3__(comment, null, debugCtx));