@depup/fast-xml-parser 5.5.6-depup.0

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +752 -0
  2. package/LICENSE +21 -0
  3. package/README.md +31 -0
  4. package/changes.json +10 -0
  5. package/lib/fxbuilder.min.js +2 -0
  6. package/lib/fxbuilder.min.js.map +1 -0
  7. package/lib/fxp.cjs +1 -0
  8. package/lib/fxp.d.cts +595 -0
  9. package/lib/fxp.min.js +2 -0
  10. package/lib/fxp.min.js.map +1 -0
  11. package/lib/fxparser.min.js +2 -0
  12. package/lib/fxparser.min.js.map +1 -0
  13. package/lib/fxvalidator.min.js +2 -0
  14. package/lib/fxvalidator.min.js.map +1 -0
  15. package/package.json +112 -0
  16. package/src/cli/cli.js +97 -0
  17. package/src/cli/man.js +17 -0
  18. package/src/cli/read.js +43 -0
  19. package/src/fxp.d.ts +577 -0
  20. package/src/fxp.js +14 -0
  21. package/src/ignoreAttributes.js +18 -0
  22. package/src/util.js +61 -0
  23. package/src/v6/CharsSymbol.js +16 -0
  24. package/src/v6/EntitiesParser.js +106 -0
  25. package/src/v6/OptionsBuilder.js +61 -0
  26. package/src/v6/OutputBuilders/BaseOutputBuilder.js +69 -0
  27. package/src/v6/OutputBuilders/JsArrBuilder.js +103 -0
  28. package/src/v6/OutputBuilders/JsMinArrBuilder.js +100 -0
  29. package/src/v6/OutputBuilders/JsObjBuilder.js +154 -0
  30. package/src/v6/OutputBuilders/ParserOptionsBuilder.js +94 -0
  31. package/src/v6/Report.js +0 -0
  32. package/src/v6/TagPath.js +81 -0
  33. package/src/v6/TagPathMatcher.js +13 -0
  34. package/src/v6/XMLParser.js +83 -0
  35. package/src/v6/Xml2JsParser.js +235 -0
  36. package/src/v6/XmlPartReader.js +210 -0
  37. package/src/v6/XmlSpecialTagsReader.js +111 -0
  38. package/src/v6/inputSource/BufferSource.js +116 -0
  39. package/src/v6/inputSource/StringSource.js +121 -0
  40. package/src/v6/valueParsers/EntitiesParser.js +105 -0
  41. package/src/v6/valueParsers/booleanParser.js +22 -0
  42. package/src/v6/valueParsers/booleanParserExt.js +19 -0
  43. package/src/v6/valueParsers/currency.js +38 -0
  44. package/src/v6/valueParsers/join.js +13 -0
  45. package/src/v6/valueParsers/number.js +14 -0
  46. package/src/v6/valueParsers/trim.js +6 -0
  47. package/src/validator.js +425 -0
  48. package/src/xmlbuilder/json2xml.js +6 -0
  49. package/src/xmlparser/DocTypeReader.js +401 -0
  50. package/src/xmlparser/OptionsBuilder.js +159 -0
  51. package/src/xmlparser/OrderedObjParser.js +905 -0
  52. package/src/xmlparser/XMLParser.js +71 -0
  53. package/src/xmlparser/node2json.js +174 -0
  54. package/src/xmlparser/xmlNode.js +40 -0
package/src/fxp.d.ts ADDED
@@ -0,0 +1,577 @@
1
+ //import type { Matcher, Expression } from 'path-expression-matcher';
2
+
3
+ type Matcher = unknown;
4
+ type Expression = unknown;
5
+
6
+ export type ProcessEntitiesOptions = {
7
+ /**
8
+ * Whether to enable entity processing
9
+ *
10
+ * Defaults to `true`
11
+ */
12
+ enabled?: boolean;
13
+
14
+ /**
15
+ * Maximum size in characters for a single entity definition
16
+ *
17
+ * Defaults to `10000`
18
+ */
19
+ maxEntitySize?: number;
20
+
21
+ /**
22
+ * Maximum depth for nested entity references (reserved for future use)
23
+ *
24
+ * Defaults to `10`
25
+ */
26
+ maxExpansionDepth?: number;
27
+
28
+ /**
29
+ * Maximum total number of entity expansions allowed
30
+ *
31
+ * Defaults to `1000`
32
+ */
33
+ maxTotalExpansions?: number;
34
+
35
+ /**
36
+ * Maximum total expanded content length in characters
37
+ *
38
+ * Defaults to `100000`
39
+ */
40
+ maxExpandedLength?: number;
41
+
42
+ /**
43
+ * Maximum number of entities allowed in the XML
44
+ *
45
+ * Defaults to `100`
46
+ */
47
+ maxEntityCount?: number;
48
+
49
+ /**
50
+ * Array of tag names where entity replacement is allowed.
51
+ * If null, entities are replaced in all tags.
52
+ *
53
+ * Defaults to `null`
54
+ */
55
+ allowedTags?: string[] | null;
56
+
57
+ /**
58
+ * Custom filter function to determine if entities should be replaced in a tag
59
+ *
60
+ * @param tagName - The name of the current tag
61
+ * @param jPathOrMatcher - The jPath string (if jPath: true) or Matcher instance (if jPath: false)
62
+ * @returns `true` to allow entity replacement, `false` to skip
63
+ *
64
+ * Defaults to `null`
65
+ */
66
+ tagFilter?: ((tagName: string, jPathOrMatcher: string | Matcher) => boolean) | null;
67
+ };
68
+
69
+ export type X2jOptions = {
70
+ /**
71
+ * Preserve the order of tags in resulting JS object
72
+ *
73
+ * Defaults to `false`
74
+ */
75
+ preserveOrder?: boolean;
76
+
77
+ /**
78
+ * Give a prefix to the attribute name in the resulting JS object
79
+ *
80
+ * Defaults to '@_'
81
+ */
82
+ attributeNamePrefix?: string;
83
+
84
+ /**
85
+ * A name to group all attributes of a tag under, or `false` to disable
86
+ *
87
+ * Defaults to `false`
88
+ */
89
+ attributesGroupName?: false | string;
90
+
91
+ /**
92
+ * The name of the next node in the resulting JS
93
+ *
94
+ * Defaults to `#text`
95
+ */
96
+ textNodeName?: string;
97
+
98
+ /**
99
+ * Whether to ignore attributes when parsing
100
+ *
101
+ * When `true` - ignores all the attributes
102
+ *
103
+ * When `false` - parses all the attributes
104
+ *
105
+ * When `Array<string | RegExp>` - filters out attributes that match provided patterns
106
+ *
107
+ * When `Function` - calls the function for each attribute and filters out those for which the function returned `true`
108
+ *
109
+ * Defaults to `true`
110
+ */
111
+ ignoreAttributes?: boolean | (string | RegExp)[] | ((attrName: string, jPathOrMatcher: string | Matcher) => boolean);
112
+
113
+ /**
114
+ * Whether to remove namespace string from tag and attribute names
115
+ *
116
+ * Defaults to `false`
117
+ */
118
+ removeNSPrefix?: boolean;
119
+
120
+ /**
121
+ * Whether to allow attributes without value
122
+ *
123
+ * Defaults to `false`
124
+ */
125
+ allowBooleanAttributes?: boolean;
126
+
127
+ /**
128
+ * Whether to parse tag value with `strnum` package
129
+ *
130
+ * Defaults to `true`
131
+ */
132
+ parseTagValue?: boolean;
133
+
134
+ /**
135
+ * Whether to parse attribute value with `strnum` package
136
+ *
137
+ * Defaults to `false`
138
+ */
139
+ parseAttributeValue?: boolean;
140
+
141
+ /**
142
+ * Whether to remove surrounding whitespace from tag or attribute value
143
+ *
144
+ * Defaults to `true`
145
+ */
146
+ trimValues?: boolean;
147
+
148
+ /**
149
+ * Give a property name to set CDATA values to instead of merging to tag's text value
150
+ *
151
+ * Defaults to `false`
152
+ */
153
+ cdataPropName?: false | string;
154
+
155
+ /**
156
+ * If set, parse comments and set as this property
157
+ *
158
+ * Defaults to `false`
159
+ */
160
+ commentPropName?: false | string;
161
+
162
+ /**
163
+ * Control how tag value should be parsed. Called only if tag value is not empty
164
+ *
165
+ * @param tagName - The name of the tag
166
+ * @param tagValue - The value of the tag
167
+ * @param jPathOrMatcher - The jPath string (if jPath: true) or Matcher instance (if jPath: false)
168
+ * @param hasAttributes - Whether the tag has attributes
169
+ * @param isLeafNode - Whether the tag is a leaf node
170
+ * @returns {undefined|null} `undefined` or `null` to set original value.
171
+ * @returns {unknown}
172
+ *
173
+ * 1. Different value or value with different data type to set new value.
174
+ * 2. Same value to set parsed value if `parseTagValue: true`.
175
+ *
176
+ * Defaults to `(tagName, val, jPathOrMatcher, hasAttributes, isLeafNode) => val`
177
+ */
178
+ tagValueProcessor?: (tagName: string, tagValue: string, jPathOrMatcher: string | Matcher, hasAttributes: boolean, isLeafNode: boolean) => unknown;
179
+
180
+ /**
181
+ * Control how attribute value should be parsed
182
+ *
183
+ * @param attrName - The name of the attribute
184
+ * @param attrValue - The value of the attribute
185
+ * @param jPathOrMatcher - The jPath string (if jPath: true) or Matcher instance (if jPath: false)
186
+ * @returns {undefined|null} `undefined` or `null` to set original value
187
+ * @returns {unknown}
188
+ *
189
+ * Defaults to `(attrName, val, jPathOrMatcher) => val`
190
+ */
191
+ attributeValueProcessor?: (attrName: string, attrValue: string, jPathOrMatcher: string | Matcher) => unknown;
192
+
193
+ /**
194
+ * Options to pass to `strnum` for parsing numbers
195
+ *
196
+ * Defaults to `{ hex: true, leadingZeros: true, eNotation: true }`
197
+ */
198
+ numberParseOptions?: strnumOptions;
199
+
200
+ /**
201
+ * Nodes to stop parsing at
202
+ *
203
+ * Accepts string patterns or Expression objects from path-expression-matcher
204
+ *
205
+ * String patterns starting with "*." are automatically converted to ".." for backward compatibility
206
+ *
207
+ * Defaults to `[]`
208
+ */
209
+ stopNodes?: (string | Expression)[];
210
+
211
+ /**
212
+ * List of tags without closing tags
213
+ *
214
+ * Defaults to `[]`
215
+ */
216
+ unpairedTags?: string[];
217
+
218
+ /**
219
+ * Whether to always create a text node
220
+ *
221
+ * Defaults to `false`
222
+ */
223
+ alwaysCreateTextNode?: boolean;
224
+
225
+ /**
226
+ * Determine whether a tag should be parsed as an array
227
+ *
228
+ * @param tagName - The name of the tag
229
+ * @param jPathOrMatcher - The jPath string (if jPath: true) or Matcher instance (if jPath: false)
230
+ * @param isLeafNode - Whether the tag is a leaf node
231
+ * @param isAttribute - Whether this is an attribute
232
+ * @returns {boolean}
233
+ *
234
+ * Defaults to `() => false`
235
+ */
236
+ isArray?: (tagName: string, jPathOrMatcher: string | Matcher, isLeafNode: boolean, isAttribute: boolean) => boolean;
237
+
238
+ /**
239
+ * Whether to process default and DOCTYPE entities
240
+ *
241
+ * When `true` - enables entity processing with default limits
242
+ *
243
+ * When `false` - disables all entity processing
244
+ *
245
+ * When `ProcessEntitiesOptions` - enables entity processing with custom configuration
246
+ *
247
+ * Defaults to `true`
248
+ */
249
+ processEntities?: boolean | ProcessEntitiesOptions;
250
+
251
+ /**
252
+ * Whether to process HTML entities
253
+ *
254
+ * Defaults to `false`
255
+ */
256
+ htmlEntities?: boolean;
257
+
258
+ /**
259
+ * Whether to ignore the declaration tag from output
260
+ *
261
+ * Defaults to `false`
262
+ */
263
+ ignoreDeclaration?: boolean;
264
+
265
+ /**
266
+ * Whether to ignore Pi tags
267
+ *
268
+ * Defaults to `false`
269
+ */
270
+ ignorePiTags?: boolean;
271
+
272
+ /**
273
+ * Transform tag names
274
+ *
275
+ * Defaults to `false`
276
+ */
277
+ transformTagName?: ((tagName: string) => string) | false;
278
+
279
+ /**
280
+ * Transform attribute names
281
+ *
282
+ * Defaults to `false`
283
+ */
284
+ transformAttributeName?: ((attributeName: string) => string) | false;
285
+
286
+ /**
287
+ * Change the tag name when a different name is returned. Skip the tag from parsed result when false is returned.
288
+ * Modify `attrs` object to control attributes for the given tag.
289
+ *
290
+ * @param tagName - The name of the tag
291
+ * @param jPathOrMatcher - The jPath string (if jPath: true) or Matcher instance (if jPath: false)
292
+ * @param attrs - The attributes object
293
+ * @returns {string} new tag name.
294
+ * @returns false to skip the tag
295
+ *
296
+ * Defaults to `(tagName, jPathOrMatcher, attrs) => tagName`
297
+ */
298
+ updateTag?: (tagName: string, jPathOrMatcher: string | Matcher, attrs: { [k: string]: string }) => string | boolean;
299
+
300
+ /**
301
+ * If true, adds a Symbol to all object nodes, accessible by {@link XMLParser.getMetaDataSymbol} with
302
+ * metadata about each the node in the XML file.
303
+ */
304
+ captureMetaData?: boolean;
305
+
306
+ /**
307
+ * Maximum number of nested tags
308
+ *
309
+ * Defaults to `100`
310
+ */
311
+ maxNestedTags?: number;
312
+
313
+ /**
314
+ * Whether to strictly validate tag names
315
+ *
316
+ * Defaults to `true`
317
+ */
318
+ strictReservedNames?: boolean;
319
+
320
+ /**
321
+ * Controls whether callbacks receive jPath as string or Matcher instance
322
+ *
323
+ * When `true` - callbacks receive jPath as string (backward compatible)
324
+ *
325
+ * When `false` - callbacks receive Matcher instance for advanced pattern matching
326
+ *
327
+ * Defaults to `true`
328
+ */
329
+ jPath?: boolean;
330
+
331
+ /**
332
+ * Function to sanitize dangerous property names
333
+ *
334
+ * @param name - The name of the property
335
+ * @returns {string} The sanitized name
336
+ *
337
+ * Defaults to `(name) => __name`
338
+ */
339
+ onDangerousProperty?: (name: string) => string;
340
+ };
341
+
342
+
343
+
344
+ export type strnumOptions = {
345
+ hex: boolean;
346
+ leadingZeros: boolean,
347
+ skipLike?: RegExp,
348
+ eNotation?: boolean
349
+ }
350
+
351
+ export type validationOptions = {
352
+ /**
353
+ * Whether to allow attributes without value
354
+ *
355
+ * Defaults to `false`
356
+ */
357
+ allowBooleanAttributes?: boolean;
358
+
359
+ /**
360
+ * List of tags without closing tags
361
+ *
362
+ * Defaults to `[]`
363
+ */
364
+ unpairedTags?: string[];
365
+ };
366
+
367
+ export type XmlBuilderOptions = {
368
+ /**
369
+ * Give a prefix to the attribute name in the resulting JS object
370
+ *
371
+ * Defaults to '@_'
372
+ */
373
+ attributeNamePrefix?: string;
374
+
375
+ /**
376
+ * A name to group all attributes of a tag under, or `false` to disable
377
+ *
378
+ * Defaults to `false`
379
+ */
380
+ attributesGroupName?: false | string;
381
+
382
+ /**
383
+ * The name of the next node in the resulting JS
384
+ *
385
+ * Defaults to `#text`
386
+ */
387
+ textNodeName?: string;
388
+
389
+ /**
390
+ * Whether to ignore attributes when building
391
+ *
392
+ * When `true` - ignores all the attributes
393
+ *
394
+ * When `false` - builds all the attributes
395
+ *
396
+ * When `Array<string | RegExp>` - filters out attributes that match provided patterns
397
+ *
398
+ * When `Function` - calls the function for each attribute and filters out those for which the function returned `true`
399
+ *
400
+ * Defaults to `true`
401
+ */
402
+ ignoreAttributes?: boolean | (string | RegExp)[] | ((attrName: string, jPath: string) => boolean);
403
+
404
+ /**
405
+ * Give a property name to set CDATA values to instead of merging to tag's text value
406
+ *
407
+ * Defaults to `false`
408
+ */
409
+ cdataPropName?: false | string;
410
+
411
+ /**
412
+ * If set, parse comments and set as this property
413
+ *
414
+ * Defaults to `false`
415
+ */
416
+ commentPropName?: false | string;
417
+
418
+ /**
419
+ * Whether to make output pretty instead of single line
420
+ *
421
+ * Defaults to `false`
422
+ */
423
+ format?: boolean;
424
+
425
+
426
+ /**
427
+ * If `format` is set to `true`, sets the indent string
428
+ *
429
+ * Defaults to ` `
430
+ */
431
+ indentBy?: string;
432
+
433
+ /**
434
+ * Give a name to a top-level array
435
+ *
436
+ * Defaults to `undefined`
437
+ */
438
+ arrayNodeName?: string;
439
+
440
+ /**
441
+ * Create empty tags for tags with no text value
442
+ *
443
+ * Defaults to `false`
444
+ */
445
+ suppressEmptyNode?: boolean;
446
+
447
+ /**
448
+ * Suppress an unpaired tag
449
+ *
450
+ * Defaults to `true`
451
+ */
452
+ suppressUnpairedNode?: boolean;
453
+
454
+ /**
455
+ * Don't put a value for boolean attributes
456
+ *
457
+ * Defaults to `true`
458
+ */
459
+ suppressBooleanAttributes?: boolean;
460
+
461
+ /**
462
+ * Preserve the order of tags in resulting JS object
463
+ *
464
+ * Defaults to `false`
465
+ */
466
+ preserveOrder?: boolean;
467
+
468
+ /**
469
+ * List of tags without closing tags
470
+ *
471
+ * Defaults to `[]`
472
+ */
473
+ unpairedTags?: string[];
474
+
475
+ /**
476
+ * Nodes to stop parsing at
477
+ *
478
+ * Accepts string patterns or Expression objects from path-expression-matcher
479
+ *
480
+ * Defaults to `[]`
481
+ */
482
+ stopNodes?: (string | Expression)[];
483
+
484
+ /**
485
+ * Control how tag value should be parsed. Called only if tag value is not empty
486
+ *
487
+ * @returns {undefined|null} `undefined` or `null` to set original value.
488
+ * @returns {unknown}
489
+ *
490
+ * 1. Different value or value with different data type to set new value.
491
+ * 2. Same value to set parsed value if `parseTagValue: true`.
492
+ *
493
+ * Defaults to `(tagName, val, jPath, hasAttributes, isLeafNode) => val`
494
+ */
495
+ tagValueProcessor?: (name: string, value: unknown) => unknown;
496
+
497
+ /**
498
+ * Control how attribute value should be parsed
499
+ *
500
+ * @param attrName
501
+ * @param attrValue
502
+ * @param jPath
503
+ * @returns {undefined|null} `undefined` or `null` to set original value
504
+ * @returns {unknown}
505
+ *
506
+ * Defaults to `(attrName, val, jPath) => val`
507
+ */
508
+ attributeValueProcessor?: (name: string, value: unknown) => unknown;
509
+
510
+ /**
511
+ * Whether to process default and DOCTYPE entities
512
+ *
513
+ * Defaults to `true`
514
+ */
515
+ processEntities?: boolean;
516
+
517
+
518
+ oneListGroup?: boolean;
519
+
520
+ /**
521
+ * Maximum number of nested tags
522
+ *
523
+ * Defaults to `100`
524
+ */
525
+ maxNestedTags?: number;
526
+ };
527
+
528
+ type ESchema = string | object | Array<string | object>;
529
+
530
+ export type ValidationError = {
531
+ err: {
532
+ code: string;
533
+ msg: string,
534
+ line: number,
535
+ col: number
536
+ };
537
+ };
538
+
539
+ export class XMLParser {
540
+ constructor(options?: X2jOptions);
541
+ parse(xmlData: string | Uint8Array, validationOptions?: validationOptions | boolean): any;
542
+ /**
543
+ * Add Entity which is not by default supported by this library
544
+ * @param entityIdentifier {string} Eg: 'ent' for &ent;
545
+ * @param entityValue {string} Eg: '\r'
546
+ */
547
+ addEntity(entityIdentifier: string, entityValue: string): void;
548
+
549
+ /**
550
+ * Returns a Symbol that can be used to access the {@link XMLMetaData}
551
+ * property on a node.
552
+ *
553
+ * If Symbol is not available in the environment, an ordinary property is used
554
+ * and the name of the property is here returned.
555
+ *
556
+ * The XMLMetaData property is only present when {@link X2jOptions.captureMetaData}
557
+ * is true in the options.
558
+ */
559
+ static getMetaDataSymbol(): Symbol;
560
+ }
561
+
562
+ export class XMLValidator {
563
+ static validate(xmlData: string, options?: validationOptions): true | ValidationError;
564
+ }
565
+ export class XMLBuilder {
566
+ constructor(options?: XmlBuilderOptions);
567
+ build(jObj: any): string;
568
+ }
569
+
570
+ /**
571
+ * This object is available on nodes via the symbol {@link XMLParser.getMetaDataSymbol}
572
+ * when {@link X2jOptions.captureMetaData} is true.
573
+ */
574
+ export interface XMLMetaData {
575
+ /** The index, if available, of the character where the XML node began in the input stream. */
576
+ startIndex?: number;
577
+ }
package/src/fxp.js ADDED
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ import { validate } from './validator.js';
4
+ import XMLParser from './xmlparser/XMLParser.js';
5
+ import XMLBuilder from './xmlbuilder/json2xml.js';
6
+
7
+ const XMLValidator = {
8
+ validate: validate
9
+ }
10
+ export {
11
+ XMLParser,
12
+ XMLValidator,
13
+ XMLBuilder
14
+ };
@@ -0,0 +1,18 @@
1
+ export default function getIgnoreAttributesFn(ignoreAttributes) {
2
+ if (typeof ignoreAttributes === 'function') {
3
+ return ignoreAttributes
4
+ }
5
+ if (Array.isArray(ignoreAttributes)) {
6
+ return (attrName) => {
7
+ for (const pattern of ignoreAttributes) {
8
+ if (typeof pattern === 'string' && attrName === pattern) {
9
+ return true
10
+ }
11
+ if (pattern instanceof RegExp && pattern.test(attrName)) {
12
+ return true
13
+ }
14
+ }
15
+ }
16
+ }
17
+ return () => false
18
+ }
package/src/util.js ADDED
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+
3
+ const nameStartChar = ':A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
4
+ const nameChar = nameStartChar + '\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040';
5
+ export const nameRegexp = '[' + nameStartChar + '][' + nameChar + ']*';
6
+ const regexName = new RegExp('^' + nameRegexp + '$');
7
+
8
+ export function getAllMatches(string, regex) {
9
+ const matches = [];
10
+ let match = regex.exec(string);
11
+ while (match) {
12
+ const allmatches = [];
13
+ allmatches.startIndex = regex.lastIndex - match[0].length;
14
+ const len = match.length;
15
+ for (let index = 0; index < len; index++) {
16
+ allmatches.push(match[index]);
17
+ }
18
+ matches.push(allmatches);
19
+ match = regex.exec(string);
20
+ }
21
+ return matches;
22
+ }
23
+
24
+ export const isName = function (string) {
25
+ const match = regexName.exec(string);
26
+ return !(match === null || typeof match === 'undefined');
27
+ }
28
+
29
+ export function isExist(v) {
30
+ return typeof v !== 'undefined';
31
+ }
32
+
33
+ export function isEmptyObject(obj) {
34
+ return Object.keys(obj).length === 0;
35
+ }
36
+
37
+ export function getValue(v) {
38
+ if (exports.isExist(v)) {
39
+ return v;
40
+ } else {
41
+ return '';
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Dangerous property names that could lead to prototype pollution or security issues
47
+ */
48
+ export const DANGEROUS_PROPERTY_NAMES = [
49
+ // '__proto__',
50
+ // 'constructor',
51
+ // 'prototype',
52
+ 'hasOwnProperty',
53
+ 'toString',
54
+ 'valueOf',
55
+ '__defineGetter__',
56
+ '__defineSetter__',
57
+ '__lookupGetter__',
58
+ '__lookupSetter__'
59
+ ];
60
+
61
+ export const criticalProperties = ["__proto__", "constructor", "prototype"];
@@ -0,0 +1,16 @@
1
+ export default {
2
+ "<" : "<", //tag start
3
+ ">" : ">", //tag end
4
+ "/" : "/", //close tag
5
+ "!" : "!", //comment or docttype
6
+ "!--" : "!--", //comment
7
+ "-->" : "-->", //comment end
8
+ "?" : "?", //pi
9
+ "?>" : "?>", //pi end
10
+ "?xml" : "?xml", //pi end
11
+ "![" : "![", //cdata
12
+ "]]>" : "]]>", //cdata end
13
+ "[" : "[",
14
+ "-" : "-",
15
+ "D" : "D",
16
+ }