fast-xml-parser 5.3.8 → 5.3.9

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/src/fxp.d.ts CHANGED
@@ -285,6 +285,13 @@ export type X2jOptions = {
285
285
  * Defaults to `100`
286
286
  */
287
287
  maxNestedTags?: number;
288
+
289
+ /**
290
+ * Whether to strictly validate tag names
291
+ *
292
+ * Defaults to `true`
293
+ */
294
+ strictReservedNames?: boolean;
288
295
  };
289
296
 
290
297
 
@@ -39,6 +39,7 @@ export const defaultOptions = {
39
39
  // skipEmptyListItem: false
40
40
  captureMetaData: false,
41
41
  maxNestedTags: 100,
42
+ strictReservedNames: true,
42
43
  };
43
44
 
44
45
  /**
@@ -163,6 +163,7 @@ function buildAttributesMap(attrStr, jPath, tagName) {
163
163
  aName = this.options.transformAttributeName(aName);
164
164
  }
165
165
  if (aName === "__proto__") aName = "#__proto__";
166
+
166
167
  if (oldVal !== undefined) {
167
168
  if (this.options.trimValues) {
168
169
  oldVal = oldVal.trim();
@@ -322,6 +323,13 @@ const parseXml = function (xmlData) {
322
323
  tagName = newTagName;
323
324
  }
324
325
 
326
+ if (this.options.strictReservedNames &&
327
+ (tagName === this.options.commentPropName
328
+ || tagName === this.options.cdataPropName
329
+ )) {
330
+ throw new Error(`Invalid tag name: ${tagName}`);
331
+ }
332
+
325
333
  //save text as child node
326
334
  if (currentNode && textData) {
327
335
  if (currentNode.tagname !== '!xml') {