@cdklabs/cdk-ecs-codedeploy 0.0.428 → 0.0.430

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 (100) hide show
  1. package/.jsii +3 -3
  2. package/.jsii.tabl.json +1 -1
  3. package/lib/api-canary/index.js +1 -1
  4. package/lib/ecs-appspec/index.js +1 -1
  5. package/lib/ecs-deployment/index.js +1 -1
  6. package/lib/ecs-patterns/application-load-balanced-codedeployed-fargate-service.js +1 -1
  7. package/node_modules/@aws-sdk/client-codedeploy/node_modules/@aws-sdk/util-endpoints/package.json +1 -1
  8. package/node_modules/@aws-sdk/client-codedeploy/package.json +12 -12
  9. package/node_modules/@aws-sdk/client-sso/package.json +11 -11
  10. package/node_modules/@aws-sdk/core/package.json +4 -4
  11. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  12. package/node_modules/@aws-sdk/credential-provider-http/package.json +3 -3
  13. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  14. package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
  15. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  16. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  17. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  18. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  19. package/node_modules/@aws-sdk/middleware-user-agent/package.json +4 -4
  20. package/node_modules/@aws-sdk/nested-clients/package.json +11 -11
  21. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  22. package/node_modules/@aws-sdk/util-endpoints/package.json +1 -1
  23. package/node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js +12 -1
  24. package/node_modules/@aws-sdk/util-user-agent-node/dist-es/defaultUserAgent.js +4 -2
  25. package/node_modules/@aws-sdk/util-user-agent-node/dist-es/getRuntimeUserAgentPair.js +10 -0
  26. package/node_modules/@aws-sdk/util-user-agent-node/dist-types/defaultUserAgent.d.ts +1 -1
  27. package/node_modules/@aws-sdk/util-user-agent-node/dist-types/getRuntimeUserAgentPair.d.ts +6 -0
  28. package/node_modules/@aws-sdk/util-user-agent-node/dist-types/ts3.4/getRuntimeUserAgentPair.d.ts +2 -0
  29. package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
  30. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/CHANGELOG.md +13 -0
  31. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.cjs +1 -1
  32. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.d.cts +83 -14
  33. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js +1 -1
  34. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -1
  35. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js +1 -1
  36. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -1
  37. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/package.json +4 -4
  38. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/fxp.d.ts +74 -12
  39. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +7 -5
  40. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +65 -53
  41. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +84 -44
  42. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +255 -187
  43. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  44. package/node_modules/@smithy/abort-controller/package.json +6 -6
  45. package/node_modules/@smithy/config-resolver/package.json +10 -10
  46. package/node_modules/@smithy/core/dist-cjs/index.js +1 -4
  47. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +3 -0
  48. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +3 -1
  49. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +1 -4
  50. package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +3 -0
  51. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +3 -1
  52. package/node_modules/@smithy/core/package.json +11 -11
  53. package/node_modules/@smithy/credential-provider-imds/package.json +9 -9
  54. package/node_modules/@smithy/fetch-http-handler/package.json +10 -10
  55. package/node_modules/@smithy/hash-node/package.json +8 -8
  56. package/node_modules/@smithy/invalid-dependency/package.json +6 -6
  57. package/node_modules/@smithy/is-array-buffer/package.json +5 -5
  58. package/node_modules/@smithy/middleware-content-length/package.json +7 -7
  59. package/node_modules/@smithy/middleware-endpoint/package.json +8 -8
  60. package/node_modules/@smithy/middleware-retry/package.json +9 -9
  61. package/node_modules/@smithy/middleware-serde/package.json +7 -7
  62. package/node_modules/@smithy/middleware-stack/package.json +6 -6
  63. package/node_modules/@smithy/node-config-provider/package.json +8 -8
  64. package/node_modules/@smithy/node-http-handler/package.json +5 -5
  65. package/node_modules/@smithy/property-provider/package.json +6 -6
  66. package/node_modules/@smithy/protocol-http/package.json +6 -6
  67. package/node_modules/@smithy/querystring-builder/package.json +7 -7
  68. package/node_modules/@smithy/querystring-parser/package.json +6 -6
  69. package/node_modules/@smithy/service-error-classification/package.json +6 -6
  70. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/index.js +16 -14
  71. package/node_modules/@smithy/shared-ini-file-loader/package.json +6 -6
  72. package/node_modules/@smithy/signature-v4/package.json +12 -12
  73. package/node_modules/@smithy/smithy-client/dist-cjs/index.js +10 -15
  74. package/node_modules/@smithy/smithy-client/package.json +7 -7
  75. package/node_modules/@smithy/types/package.json +5 -5
  76. package/node_modules/@smithy/url-parser/package.json +7 -7
  77. package/node_modules/@smithy/util-base64/dist-cjs/index.js +14 -6
  78. package/node_modules/@smithy/util-base64/package.json +7 -7
  79. package/node_modules/@smithy/util-body-length-browser/package.json +5 -5
  80. package/node_modules/@smithy/util-body-length-node/package.json +5 -5
  81. package/node_modules/@smithy/util-buffer-from/package.json +6 -6
  82. package/node_modules/@smithy/util-config-provider/package.json +5 -5
  83. package/node_modules/@smithy/util-defaults-mode-browser/dist-cjs/index.js +7 -3
  84. package/node_modules/@smithy/util-defaults-mode-browser/package.json +4 -4
  85. package/node_modules/@smithy/util-defaults-mode-node/package.json +7 -7
  86. package/node_modules/@smithy/util-endpoints/package.json +7 -7
  87. package/node_modules/@smithy/util-hex-encoding/package.json +5 -5
  88. package/node_modules/@smithy/util-middleware/package.json +6 -6
  89. package/node_modules/@smithy/util-retry/package.json +7 -7
  90. package/node_modules/@smithy/util-stream/dist-cjs/checksum/ChecksumStream.js +13 -2
  91. package/node_modules/@smithy/util-stream/dist-cjs/index.js +51 -29
  92. package/node_modules/@smithy/util-stream/dist-es/checksum/ChecksumStream.js +13 -2
  93. package/node_modules/@smithy/util-stream/dist-types/checksum/ChecksumStream.d.ts +1 -0
  94. package/node_modules/@smithy/util-stream/dist-types/ts3.4/checksum/ChecksumStream.d.ts +1 -0
  95. package/node_modules/@smithy/util-stream/package.json +8 -8
  96. package/node_modules/@smithy/util-uri-escape/package.json +5 -5
  97. package/node_modules/@smithy/util-utf8/package.json +6 -6
  98. package/node_modules/@smithy/util-waiter/package.json +7 -7
  99. package/node_modules/@smithy/uuid/package.json +5 -5
  100. package/package.json +3 -3
@@ -1,3 +1,59 @@
1
+ export type ProcessEntitiesOptions = {
2
+ /**
3
+ * Whether to enable entity processing
4
+ *
5
+ * Defaults to `true`
6
+ */
7
+ enabled?: boolean;
8
+
9
+ /**
10
+ * Maximum size in characters for a single entity definition
11
+ *
12
+ * Defaults to `10000`
13
+ */
14
+ maxEntitySize?: number;
15
+
16
+ /**
17
+ * Maximum depth for nested entity references (reserved for future use)
18
+ *
19
+ * Defaults to `10`
20
+ */
21
+ maxExpansionDepth?: number;
22
+
23
+ /**
24
+ * Maximum total number of entity expansions allowed
25
+ *
26
+ * Defaults to `1000`
27
+ */
28
+ maxTotalExpansions?: number;
29
+
30
+ /**
31
+ * Maximum total expanded content length in characters
32
+ *
33
+ * Defaults to `100000`
34
+ */
35
+ maxExpandedLength?: number;
36
+
37
+ /**
38
+ * Array of tag names where entity replacement is allowed.
39
+ * If null, entities are replaced in all tags.
40
+ *
41
+ * Defaults to `null`
42
+ */
43
+ allowedTags?: string[] | null;
44
+
45
+ /**
46
+ * Custom filter function to determine if entities should be replaced in a tag
47
+ *
48
+ * @param tagName - The name of the current tag
49
+ * @param jPath - The jPath of the current tag
50
+ * @returns `true` to allow entity replacement, `false` to skip
51
+ *
52
+ * Defaults to `null`
53
+ */
54
+ tagFilter?: ((tagName: string, jPath: string) => boolean) | null;
55
+ };
56
+
1
57
  export type X2jOptions = {
2
58
  /**
3
59
  * Preserve the order of tags in resulting JS object
@@ -10,7 +66,7 @@ export type X2jOptions = {
10
66
  * Give a prefix to the attribute name in the resulting JS object
11
67
  *
12
68
  * Defaults to '@_'
13
- */
69
+ */
14
70
  attributeNamePrefix?: string;
15
71
 
16
72
  /**
@@ -161,9 +217,15 @@ export type X2jOptions = {
161
217
  /**
162
218
  * Whether to process default and DOCTYPE entities
163
219
  *
220
+ * When `true` - enables entity processing with default limits
221
+ *
222
+ * When `false` - disables all entity processing
223
+ *
224
+ * When `ProcessEntitiesOptions` - enables entity processing with custom configuration
225
+ *
164
226
  * Defaults to `true`
165
227
  */
166
- processEntities?: boolean;
228
+ processEntities?: boolean | ProcessEntitiesOptions;
167
229
 
168
230
  /**
169
231
  * Whether to process HTML entities
@@ -209,7 +271,7 @@ export type X2jOptions = {
209
271
  *
210
272
  * Defaults to `(tagName, jPath, attrs) => tagName`
211
273
  */
212
- updateTag?: (tagName: string, jPath: string, attrs: {[k: string]: string}) => string | boolean;
274
+ updateTag?: (tagName: string, jPath: string, attrs: { [k: string]: string }) => string | boolean;
213
275
 
214
276
  /**
215
277
  * If true, adds a Symbol to all object nodes, accessible by {@link XMLParser.getMetaDataSymbol} with
@@ -232,7 +294,7 @@ export type validationOptions = {
232
294
  * Defaults to `false`
233
295
  */
234
296
  allowBooleanAttributes?: boolean;
235
-
297
+
236
298
  /**
237
299
  * List of tags without closing tags
238
300
  *
@@ -246,7 +308,7 @@ export type XmlBuilderOptions = {
246
308
  * Give a prefix to the attribute name in the resulting JS object
247
309
  *
248
310
  * Defaults to '@_'
249
- */
311
+ */
250
312
  attributeNamePrefix?: string;
251
313
 
252
314
  /**
@@ -393,14 +455,14 @@ export type XmlBuilderOptions = {
393
455
  oneListGroup?: boolean;
394
456
  };
395
457
 
396
- type ESchema = string | object | Array<string|object>;
458
+ type ESchema = string | object | Array<string | object>;
397
459
 
398
460
  export type ValidationError = {
399
- err: {
461
+ err: {
400
462
  code: string;
401
463
  msg: string,
402
464
  line: number,
403
- col: number
465
+ col: number
404
466
  };
405
467
  };
406
468
 
@@ -424,11 +486,11 @@ export class XMLParser {
424
486
  * The XMLMetaData property is only present when {@link X2jOptions.captureMetaData}
425
487
  * is true in the options.
426
488
  */
427
- static getMetaDataSymbol() : Symbol;
489
+ static getMetaDataSymbol(): Symbol;
428
490
  }
429
491
 
430
- export class XMLValidator{
431
- static validate( xmlData: string, options?: validationOptions): true | ValidationError;
492
+ export class XMLValidator {
493
+ static validate(xmlData: string, options?: validationOptions): true | ValidationError;
432
494
  }
433
495
  export class XMLBuilder {
434
496
  constructor(options?: XmlBuilderOptions);
@@ -442,4 +504,4 @@ export class XMLBuilder {
442
504
  export interface XMLMetaData {
443
505
  /** The index, if available, of the character where the XML node began in the input stream. */
444
506
  startIndex?: number;
445
- }
507
+ }
@@ -37,12 +37,13 @@ export default class EntitiesParser{
37
37
  }
38
38
  addExternalEntity(key,val){
39
39
  validateEntityName(key);
40
+ const escaped = key.replace(/[.\-+*:]/g, '\\.');
40
41
  if(val.indexOf("&") !== -1) {
41
42
  reportWarning(`Entity ${key} is not added as '&' is found in value;`)
42
43
  return;
43
44
  }else{
44
- this.lastEntities[ent] = {
45
- regex: new RegExp("&"+key+";","g"),
45
+ this.lastEntities[key] = {
46
+ regex: new RegExp("&"+escaped+";","g"),
46
47
  val : val
47
48
  }
48
49
  }
@@ -52,8 +53,9 @@ export default class EntitiesParser{
52
53
  const entKeys = Object.keys(entities);
53
54
  for (let i = 0; i < entKeys.length; i++) {
54
55
  const ent = entKeys[i];
56
+ const escaped = ent.replace(/[.\-+*:]/g, '\\.');
55
57
  this.docTypeEntities[ent] = {
56
- regex: new RegExp("&"+ent+";","g"),
58
+ regex: new RegExp("&"+escaped+";","g"),
57
59
  val : entities[ent]
58
60
  }
59
61
  }
@@ -89,11 +91,11 @@ export default class EntitiesParser{
89
91
  }
90
92
  return val;
91
93
  }
92
- };
94
+ }
93
95
 
94
96
  //an entity name should not contains special characters that may be used in regex
95
97
  //Eg !?\\\/[]$%{}^&*()<>
96
- const specialChar = "!?\\\/[]$%{}^&*()<>|+";
98
+ const specialChar = "!?\\/[]$%{}^&*()<>|+";
97
99
 
98
100
  function validateEntityName(name){
99
101
  for (let i = 0; i < specialChar.length; i++) {
@@ -1,80 +1,82 @@
1
- import {isName} from '../util.js';
1
+ import { isName } from '../util.js';
2
2
 
3
- export default class DocTypeReader{
4
- constructor(processEntities){
5
- this.suppressValidationErr = !processEntities;
3
+ export default class DocTypeReader {
4
+ constructor(options) {
5
+ this.suppressValidationErr = !options;
6
+ this.options = options;
6
7
  }
7
-
8
- readDocType(xmlData, i){
9
-
8
+
9
+ readDocType(xmlData, i) {
10
+
10
11
  const entities = {};
11
- if( xmlData[i + 3] === 'O' &&
12
+ if (xmlData[i + 3] === 'O' &&
12
13
  xmlData[i + 4] === 'C' &&
13
14
  xmlData[i + 5] === 'T' &&
14
15
  xmlData[i + 6] === 'Y' &&
15
16
  xmlData[i + 7] === 'P' &&
16
- xmlData[i + 8] === 'E')
17
- {
18
- i = i+9;
17
+ xmlData[i + 8] === 'E') {
18
+ i = i + 9;
19
19
  let angleBracketsCount = 1;
20
20
  let hasBody = false, comment = false;
21
21
  let exp = "";
22
- for(;i<xmlData.length;i++){
22
+ for (; i < xmlData.length; i++) {
23
23
  if (xmlData[i] === '<' && !comment) { //Determine the tag type
24
- if( hasBody && hasSeq(xmlData, "!ENTITY",i)){
25
- i += 7;
24
+ if (hasBody && hasSeq(xmlData, "!ENTITY", i)) {
25
+ i += 7;
26
26
  let entityName, val;
27
- [entityName, val,i] = this.readEntityExp(xmlData,i+1,this.suppressValidationErr);
28
- if(val.indexOf("&") === -1) //Parameter entities are not supported
29
- entities[ entityName ] = {
30
- regx : RegExp( `&${entityName};`,"g"),
27
+ [entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
28
+ if (val.indexOf("&") === -1) { //Parameter entities are not supported
29
+ const escaped = entityName.replace(/[.\-+*:]/g, '\\.');
30
+ entities[entityName] = {
31
+ regx: RegExp(`&${escaped};`, "g"),
31
32
  val: val
32
33
  };
34
+ }
33
35
  }
34
- else if( hasBody && hasSeq(xmlData, "!ELEMENT",i)) {
36
+ else if (hasBody && hasSeq(xmlData, "!ELEMENT", i)) {
35
37
  i += 8;//Not supported
36
- const {index} = this.readElementExp(xmlData,i+1);
38
+ const { index } = this.readElementExp(xmlData, i + 1);
37
39
  i = index;
38
- }else if( hasBody && hasSeq(xmlData, "!ATTLIST",i)){
40
+ } else if (hasBody && hasSeq(xmlData, "!ATTLIST", i)) {
39
41
  i += 8;//Not supported
40
42
  // const {index} = this.readAttlistExp(xmlData,i+1);
41
43
  // i = index;
42
- }else if( hasBody && hasSeq(xmlData, "!NOTATION",i)) {
44
+ } else if (hasBody && hasSeq(xmlData, "!NOTATION", i)) {
43
45
  i += 9;//Not supported
44
- const {index} = this.readNotationExp(xmlData,i+1,this.suppressValidationErr);
46
+ const { index } = this.readNotationExp(xmlData, i + 1, this.suppressValidationErr);
45
47
  i = index;
46
- }else if( hasSeq(xmlData, "!--",i) ) comment = true;
48
+ } else if (hasSeq(xmlData, "!--", i)) comment = true;
47
49
  else throw new Error(`Invalid DOCTYPE`);
48
50
 
49
51
  angleBracketsCount++;
50
52
  exp = "";
51
53
  } else if (xmlData[i] === '>') { //Read tag content
52
- if(comment){
53
- if( xmlData[i - 1] === "-" && xmlData[i - 2] === "-"){
54
+ if (comment) {
55
+ if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
54
56
  comment = false;
55
57
  angleBracketsCount--;
56
58
  }
57
- }else{
59
+ } else {
58
60
  angleBracketsCount--;
59
61
  }
60
62
  if (angleBracketsCount === 0) {
61
- break;
63
+ break;
62
64
  }
63
- }else if( xmlData[i] === '['){
65
+ } else if (xmlData[i] === '[') {
64
66
  hasBody = true;
65
- }else{
67
+ } else {
66
68
  exp += xmlData[i];
67
69
  }
68
70
  }
69
- if(angleBracketsCount !== 0){
71
+ if (angleBracketsCount !== 0) {
70
72
  throw new Error(`Unclosed DOCTYPE`);
71
73
  }
72
- }else{
74
+ } else {
73
75
  throw new Error(`Invalid Tag instead of DOCTYPE`);
74
76
  }
75
- return {entities, i};
77
+ return { entities, i };
76
78
  }
77
- readEntityExp(xmlData, i) {
79
+ readEntityExp(xmlData, i) {
78
80
  //External entities are not supported
79
81
  // <!ENTITY ext SYSTEM "http://normal-website.com" >
80
82
 
@@ -99,10 +101,10 @@ export default class DocTypeReader{
99
101
  i = skipWhitespace(xmlData, i);
100
102
 
101
103
  // Check for unsupported constructs (external entities or parameter entities)
102
- if(!this.suppressValidationErr){
104
+ if (!this.suppressValidationErr) {
103
105
  if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
104
106
  throw new Error("External entities are not supported");
105
- }else if (xmlData[i] === "%") {
107
+ } else if (xmlData[i] === "%") {
106
108
  throw new Error("Parameter entities are not supported");
107
109
  }
108
110
  }
@@ -110,8 +112,18 @@ export default class DocTypeReader{
110
112
  // Read entity value (internal entity)
111
113
  let entityValue = "";
112
114
  [i, entityValue] = this.readIdentifierVal(xmlData, i, "entity");
115
+
116
+ // Validate entity size
117
+ if (this.options.enabled !== false &&
118
+ this.options.maxEntitySize &&
119
+ entityValue.length > this.options.maxEntitySize) {
120
+ throw new Error(
121
+ `Entity "${entityName}" size (${entityValue.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`
122
+ );
123
+ }
124
+
113
125
  i--;
114
- return [entityName, entityValue, i ];
126
+ return [entityName, entityValue, i];
115
127
  }
116
128
 
117
129
  readNotationExp(xmlData, i) {
@@ -144,25 +156,25 @@ export default class DocTypeReader{
144
156
  let systemIdentifier = null;
145
157
 
146
158
  if (identifierType === "PUBLIC") {
147
- [i, publicIdentifier ] = this.readIdentifierVal(xmlData, i, "publicIdentifier");
159
+ [i, publicIdentifier] = this.readIdentifierVal(xmlData, i, "publicIdentifier");
148
160
 
149
161
  // Skip whitespace after public identifier
150
162
  i = skipWhitespace(xmlData, i);
151
163
 
152
164
  // Optionally read system identifier
153
165
  if (xmlData[i] === '"' || xmlData[i] === "'") {
154
- [i, systemIdentifier ] = this.readIdentifierVal(xmlData, i,"systemIdentifier");
166
+ [i, systemIdentifier] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
155
167
  }
156
168
  } else if (identifierType === "SYSTEM") {
157
169
  // Read system identifier (mandatory for SYSTEM)
158
- [i, systemIdentifier ] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
170
+ [i, systemIdentifier] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
159
171
 
160
172
  if (!this.suppressValidationErr && !systemIdentifier) {
161
173
  throw new Error("Missing mandatory system identifier for SYSTEM notation");
162
174
  }
163
175
  }
164
-
165
- return {notationName, publicIdentifier, systemIdentifier, index: --i};
176
+
177
+ return { notationName, publicIdentifier, systemIdentifier, index: --i };
166
178
  }
167
179
 
168
180
  readIdentifierVal(xmlData, i, type) {
@@ -191,7 +203,7 @@ export default class DocTypeReader{
191
203
  // <!ELEMENT title (#PCDATA)>
192
204
  // <!ELEMENT book (title, author+)>
193
205
  // <!ELEMENT name (content-model)>
194
-
206
+
195
207
  // Skip leading whitespace after <!ELEMENT
196
208
  i = skipWhitespace(xmlData, i);
197
209
 
@@ -211,8 +223,8 @@ export default class DocTypeReader{
211
223
  i = skipWhitespace(xmlData, i);
212
224
  let contentModel = "";
213
225
  // Expect '(' to start content model
214
- if(xmlData[i] === "E" && hasSeq(xmlData, "MPTY",i)) i+=4;
215
- else if(xmlData[i] === "A" && hasSeq(xmlData, "NY",i)) i+=2;
226
+ if (xmlData[i] === "E" && hasSeq(xmlData, "MPTY", i)) i += 4;
227
+ else if (xmlData[i] === "A" && hasSeq(xmlData, "NY", i)) i += 2;
216
228
  else if (xmlData[i] === "(") {
217
229
  i++; // Move past '('
218
230
 
@@ -225,10 +237,10 @@ export default class DocTypeReader{
225
237
  throw new Error("Unterminated content model");
226
238
  }
227
239
 
228
- }else if(!this.suppressValidationErr){
240
+ } else if (!this.suppressValidationErr) {
229
241
  throw new Error(`Invalid Element Expression, found "${xmlData[i]}"`);
230
242
  }
231
-
243
+
232
244
  return {
233
245
  elementName,
234
246
  contentModel: contentModel.trim(),
@@ -364,16 +376,16 @@ const skipWhitespace = (data, index) => {
364
376
 
365
377
 
366
378
 
367
- function hasSeq(data, seq,i){
368
- for(let j=0;j<seq.length;j++){
369
- if(seq[j]!==data[i+j+1]) return false;
379
+ function hasSeq(data, seq, i) {
380
+ for (let j = 0; j < seq.length; j++) {
381
+ if (seq[j] !== data[i + j + 1]) return false;
370
382
  }
371
383
  return true;
372
384
  }
373
385
 
374
- function validateEntityName(name){
386
+ function validateEntityName(name) {
375
387
  if (isName(name))
376
- return name;
388
+ return name;
377
389
  else
378
390
  throw new Error(`Invalid entity name ${name}`);
379
- }
391
+ }
@@ -1,46 +1,86 @@
1
-
2
1
  export const defaultOptions = {
3
- preserveOrder: false,
4
- attributeNamePrefix: '@_',
5
- attributesGroupName: false,
6
- textNodeName: '#text',
7
- ignoreAttributes: true,
8
- removeNSPrefix: false, // remove NS from tag name or attribute name if true
9
- allowBooleanAttributes: false, //a tag can have attributes without any value
10
- //ignoreRootElement : false,
11
- parseTagValue: true,
12
- parseAttributeValue: false,
13
- trimValues: true, //Trim string values of tag and attributes
14
- cdataPropName: false,
15
- numberParseOptions: {
16
- hex: true,
17
- leadingZeros: true,
18
- eNotation: true
19
- },
20
- tagValueProcessor: function(tagName, val) {
21
- return val;
22
- },
23
- attributeValueProcessor: function(attrName, val) {
24
- return val;
25
- },
26
- stopNodes: [], //nested tags will not be parsed even for errors
27
- alwaysCreateTextNode: false,
28
- isArray: () => false,
29
- commentPropName: false,
30
- unpairedTags: [],
31
- processEntities: true,
32
- htmlEntities: false,
33
- ignoreDeclaration: false,
34
- ignorePiTags: false,
35
- transformTagName: false,
36
- transformAttributeName: false,
37
- updateTag: function(tagName, jPath, attrs){
38
- return tagName
39
- },
40
- // skipEmptyListItem: false
41
- captureMetaData: false,
42
- };
43
-
44
- export const buildOptions = function(options) {
45
- return Object.assign({}, defaultOptions, options);
2
+ preserveOrder: false,
3
+ attributeNamePrefix: '@_',
4
+ attributesGroupName: false,
5
+ textNodeName: '#text',
6
+ ignoreAttributes: true,
7
+ removeNSPrefix: false, // remove NS from tag name or attribute name if true
8
+ allowBooleanAttributes: false, //a tag can have attributes without any value
9
+ //ignoreRootElement : false,
10
+ parseTagValue: true,
11
+ parseAttributeValue: false,
12
+ trimValues: true, //Trim string values of tag and attributes
13
+ cdataPropName: false,
14
+ numberParseOptions: {
15
+ hex: true,
16
+ leadingZeros: true,
17
+ eNotation: true
18
+ },
19
+ tagValueProcessor: function (tagName, val) {
20
+ return val;
21
+ },
22
+ attributeValueProcessor: function (attrName, val) {
23
+ return val;
24
+ },
25
+ stopNodes: [], //nested tags will not be parsed even for errors
26
+ alwaysCreateTextNode: false,
27
+ isArray: () => false,
28
+ commentPropName: false,
29
+ unpairedTags: [],
30
+ processEntities: true,
31
+ htmlEntities: false,
32
+ ignoreDeclaration: false,
33
+ ignorePiTags: false,
34
+ transformTagName: false,
35
+ transformAttributeName: false,
36
+ updateTag: function (tagName, jPath, attrs) {
37
+ return tagName
38
+ },
39
+ // skipEmptyListItem: false
40
+ captureMetaData: false,
46
41
  };
42
+
43
+ /**
44
+ * Normalizes processEntities option for backward compatibility
45
+ * @param {boolean|object} value
46
+ * @returns {object} Always returns normalized object
47
+ */
48
+ function normalizeProcessEntities(value) {
49
+ // Boolean backward compatibility
50
+ if (typeof value === 'boolean') {
51
+ return {
52
+ enabled: value, // true or false
53
+ maxEntitySize: 10000,
54
+ maxExpansionDepth: 10,
55
+ maxTotalExpansions: 1000,
56
+ maxExpandedLength: 100000,
57
+ allowedTags: null,
58
+ tagFilter: null
59
+ };
60
+ }
61
+
62
+ // Object config - merge with defaults
63
+ if (typeof value === 'object' && value !== null) {
64
+ return {
65
+ enabled: value.enabled !== false, // default true if not specified
66
+ maxEntitySize: value.maxEntitySize ?? 10000,
67
+ maxExpansionDepth: value.maxExpansionDepth ?? 10,
68
+ maxTotalExpansions: value.maxTotalExpansions ?? 1000,
69
+ maxExpandedLength: value.maxExpandedLength ?? 100000,
70
+ allowedTags: value.allowedTags ?? null,
71
+ tagFilter: value.tagFilter ?? null
72
+ };
73
+ }
74
+
75
+ // Default to enabled with limits
76
+ return normalizeProcessEntities(true);
77
+ }
78
+
79
+ export const buildOptions = function (options) {
80
+ const built = Object.assign({}, defaultOptions, options);
81
+
82
+ // Always normalize processEntities for backward compatibility and validation
83
+ built.processEntities = normalizeProcessEntities(built.processEntities);
84
+ //console.debug(built.processEntities)
85
+ return built;
86
+ };