@symbiotejs/symbiote 3.5.6 → 3.5.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/node/SSR.js CHANGED
@@ -56,6 +56,15 @@ function isInsidePreformatted(node) {
56
56
  return false;
57
57
  }
58
58
 
59
+ /**
60
+ * Escape HTML special characters in text content.
61
+ * @param {string} text
62
+ * @returns {string}
63
+ */
64
+ function escapeHtml(text) {
65
+ return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
66
+ }
67
+
59
68
  /**
60
69
  * Resolve {{prop}} text node tokens by reading values from the closest custom element.
61
70
  * @param {string} text
@@ -178,8 +187,8 @@ function serializeNode(node, emittedStyles, nonce) {
178
187
  }
179
188
  // Text node:
180
189
  if (node.nodeType === 3) {
181
- if (preformatted) return node.textContent || '';
182
- return resolveTextTokens(node.textContent || '', node);
190
+ if (preformatted) return escapeHtml(node.textContent || '');
191
+ return resolveTextTokens(escapeHtml(node.textContent || ''), node);
183
192
  }
184
193
  // Comment:
185
194
  if (node.nodeType === 8) {
@@ -272,9 +281,9 @@ async function* streamNode(node, emittedStyles, nonce) {
272
281
  }
273
282
  if (node.nodeType === 3) {
274
283
  if (preformatted) {
275
- yield node.textContent || '';
284
+ yield escapeHtml(node.textContent || '');
276
285
  } else {
277
- yield resolveTextTokens(node.textContent || '', node);
286
+ yield resolveTextTokens(escapeHtml(node.textContent || ''), node);
278
287
  }
279
288
  return;
280
289
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@symbiotejs/symbiote",
4
- "version": "3.5.6",
4
+ "version": "3.5.7",
5
5
  "description": "Symbiote.js - zero-dependency close-to-platform frontend library to build super-powered web components",
6
6
  "author": "team@rnd-pro.com",
7
7
  "license": "MIT",
@@ -1 +1 @@
1
- {"version":3,"file":"SSR.d.ts","sourceRoot":"","sources":["../../node/SSR.js"],"names":[],"mappings":"AA6RA;IAEE,8BAAmB;IACnB,8BAAmB;IAMnB;;;OAkEC;IAMD,uBAYC;IAkBD,yBAZW,MAAM,YACN;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAChB,OAAO,CAAC,MAAM,CAAC,CAgC3B;IAWD,+BALW,MAAM;;iBAEN;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAChB,MAAM,CAwBlB;IAWD,+BALW,MAAM;;iBAEN;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAChB,cAAc,CAAC,MAAM,CAAC,CAqBlC;CACF"}
1
+ {"version":3,"file":"SSR.d.ts","sourceRoot":"","sources":["../../node/SSR.js"],"names":[],"mappings":"AAsSA;IAEE,8BAAmB;IACnB,8BAAmB;IAMnB;;;OAkEC;IAMD,uBAYC;IAkBD,yBAZW,MAAM,YACN;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAChB,OAAO,CAAC,MAAM,CAAC,CAgC3B;IAWD,+BALW,MAAM;;iBAEN;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAChB,MAAM,CAwBlB;IAWD,+BALW,MAAM;;iBAEN;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAChB,cAAc,CAAC,MAAM,CAAC,CAqBlC;CACF"}