@cdklabs/cdk-ecs-codedeploy 0.0.179 → 0.0.181

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 (88) hide show
  1. package/.jsii +4 -4
  2. package/lib/api-canary/index.js +1 -1
  3. package/lib/ecs-appspec/index.js +1 -1
  4. package/lib/ecs-deployment/index.js +1 -1
  5. package/lib/ecs-patterns/application-load-balanced-codedeployed-fargate-service.js +1 -1
  6. package/node_modules/@aws-sdk/abort-controller/package.json +2 -2
  7. package/node_modules/@aws-sdk/client-codedeploy/package.json +29 -29
  8. package/node_modules/@aws-sdk/client-sso/package.json +25 -25
  9. package/node_modules/@aws-sdk/client-sso-oidc/package.json +25 -25
  10. package/node_modules/@aws-sdk/client-sts/package.json +29 -29
  11. package/node_modules/@aws-sdk/config-resolver/package.json +4 -4
  12. package/node_modules/@aws-sdk/credential-provider-env/package.json +3 -3
  13. package/node_modules/@aws-sdk/credential-provider-imds/package.json +5 -5
  14. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  15. package/node_modules/@aws-sdk/credential-provider-node/package.json +10 -10
  16. package/node_modules/@aws-sdk/credential-provider-process/package.json +4 -4
  17. package/node_modules/@aws-sdk/credential-provider-sso/package.json +6 -6
  18. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  19. package/node_modules/@aws-sdk/eventstream-codec/package.json +2 -2
  20. package/node_modules/@aws-sdk/fetch-http-handler/dist-cjs/fetch-http-handler.js +16 -6
  21. package/node_modules/@aws-sdk/fetch-http-handler/dist-es/fetch-http-handler.js +15 -6
  22. package/node_modules/@aws-sdk/fetch-http-handler/package.json +5 -5
  23. package/node_modules/@aws-sdk/hash-node/package.json +2 -2
  24. package/node_modules/@aws-sdk/invalid-dependency/package.json +2 -2
  25. package/node_modules/@aws-sdk/middleware-content-length/package.json +3 -3
  26. package/node_modules/@aws-sdk/middleware-endpoint/package.json +5 -5
  27. package/node_modules/@aws-sdk/middleware-host-header/package.json +3 -3
  28. package/node_modules/@aws-sdk/middleware-logger/package.json +2 -2
  29. package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +3 -3
  30. package/node_modules/@aws-sdk/middleware-retry/package.json +7 -7
  31. package/node_modules/@aws-sdk/middleware-sdk-sts/package.json +3 -3
  32. package/node_modules/@aws-sdk/middleware-serde/package.json +2 -2
  33. package/node_modules/@aws-sdk/middleware-signing/package.json +6 -6
  34. package/node_modules/@aws-sdk/middleware-stack/package.json +2 -2
  35. package/node_modules/@aws-sdk/middleware-user-agent/package.json +4 -4
  36. package/node_modules/@aws-sdk/node-config-provider/package.json +4 -4
  37. package/node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http-handler.js +17 -1
  38. package/node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http2-handler.js +18 -5
  39. package/node_modules/@aws-sdk/node-http-handler/dist-es/node-http-handler.js +16 -1
  40. package/node_modules/@aws-sdk/node-http-handler/dist-es/node-http2-handler.js +16 -3
  41. package/node_modules/@aws-sdk/node-http-handler/package.json +5 -5
  42. package/node_modules/@aws-sdk/property-provider/package.json +2 -2
  43. package/node_modules/@aws-sdk/protocol-http/dist-cjs/httpRequest.js +3 -0
  44. package/node_modules/@aws-sdk/protocol-http/dist-cjs/httpResponse.js +1 -0
  45. package/node_modules/@aws-sdk/protocol-http/dist-es/httpRequest.js +3 -0
  46. package/node_modules/@aws-sdk/protocol-http/dist-es/httpResponse.js +1 -0
  47. package/node_modules/@aws-sdk/protocol-http/dist-types/httpRequest.d.ts +6 -3
  48. package/node_modules/@aws-sdk/protocol-http/dist-types/httpResponse.d.ts +2 -0
  49. package/node_modules/@aws-sdk/protocol-http/dist-types/ts3.4/httpRequest.d.ts +6 -3
  50. package/node_modules/@aws-sdk/protocol-http/dist-types/ts3.4/httpResponse.d.ts +2 -0
  51. package/node_modules/@aws-sdk/protocol-http/package.json +2 -2
  52. package/node_modules/@aws-sdk/querystring-builder/package.json +2 -2
  53. package/node_modules/@aws-sdk/querystring-parser/package.json +2 -2
  54. package/node_modules/@aws-sdk/service-error-classification/package.json +2 -2
  55. package/node_modules/@aws-sdk/shared-ini-file-loader/package.json +2 -2
  56. package/node_modules/@aws-sdk/signature-v4/package.json +5 -5
  57. package/node_modules/@aws-sdk/smithy-client/package.json +3 -3
  58. package/node_modules/@aws-sdk/token-providers/package.json +5 -5
  59. package/node_modules/@aws-sdk/types/dist-cjs/index.js +1 -0
  60. package/node_modules/@aws-sdk/types/dist-cjs/uri.js +2 -0
  61. package/node_modules/@aws-sdk/types/dist-es/index.js +1 -0
  62. package/node_modules/@aws-sdk/types/dist-es/uri.js +1 -0
  63. package/node_modules/@aws-sdk/types/dist-types/http.d.ts +3 -1
  64. package/node_modules/@aws-sdk/types/dist-types/index.d.ts +1 -0
  65. package/node_modules/@aws-sdk/types/dist-types/ts3.4/http.d.ts +3 -1
  66. package/node_modules/@aws-sdk/types/dist-types/ts3.4/index.d.ts +1 -0
  67. package/node_modules/@aws-sdk/types/dist-types/ts3.4/uri.d.ts +11 -0
  68. package/node_modules/@aws-sdk/types/dist-types/uri.d.ts +17 -0
  69. package/node_modules/@aws-sdk/types/package.json +1 -1
  70. package/node_modules/@aws-sdk/url-parser/package.json +3 -3
  71. package/node_modules/@aws-sdk/util-defaults-mode-browser/package.json +4 -4
  72. package/node_modules/@aws-sdk/util-defaults-mode-node/package.json +7 -7
  73. package/node_modules/@aws-sdk/util-endpoints/package.json +2 -2
  74. package/node_modules/@aws-sdk/util-middleware/package.json +2 -2
  75. package/node_modules/@aws-sdk/util-retry/package.json +3 -3
  76. package/node_modules/@aws-sdk/util-user-agent-browser/package.json +2 -2
  77. package/node_modules/@aws-sdk/util-user-agent-node/package.json +3 -3
  78. package/node_modules/@aws-sdk/util-waiter/package.json +3 -3
  79. package/node_modules/fast-xml-parser/CHANGELOG.md +26 -0
  80. package/node_modules/fast-xml-parser/README.md +1 -0
  81. package/node_modules/fast-xml-parser/package.json +7 -4
  82. package/node_modules/fast-xml-parser/src/fxp.d.ts +10 -1
  83. package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +12 -2
  84. package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +108 -71
  85. package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +4 -0
  86. package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +43 -20
  87. package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +13 -1
  88. package/package.json +7 -7
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/util-retry",
3
- "version": "3.342.0",
3
+ "version": "3.347.0",
4
4
  "description": "Shared retry utilities to be used in middleware packages.",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -25,11 +25,11 @@
25
25
  },
26
26
  "license": "Apache-2.0",
27
27
  "dependencies": {
28
- "@aws-sdk/service-error-classification": "3.342.0",
28
+ "@aws-sdk/service-error-classification": "3.347.0",
29
29
  "tslib": "^2.5.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@aws-sdk/types": "3.342.0",
32
+ "@aws-sdk/types": "3.347.0",
33
33
  "@tsconfig/recommended": "1.0.1",
34
34
  "@types/node": "^14.14.31",
35
35
  "concurrently": "7.0.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/util-user-agent-browser",
3
- "version": "3.345.0",
3
+ "version": "3.347.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",
@@ -21,7 +21,7 @@
21
21
  "license": "Apache-2.0",
22
22
  "react-native": "dist-es/index.native.js",
23
23
  "dependencies": {
24
- "@aws-sdk/types": "3.342.0",
24
+ "@aws-sdk/types": "3.347.0",
25
25
  "bowser": "^2.11.0",
26
26
  "tslib": "^2.5.0"
27
27
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/util-user-agent-node",
3
- "version": "3.345.0",
3
+ "version": "3.347.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",
@@ -20,8 +20,8 @@
20
20
  },
21
21
  "license": "Apache-2.0",
22
22
  "dependencies": {
23
- "@aws-sdk/node-config-provider": "3.342.0",
24
- "@aws-sdk/types": "3.342.0",
23
+ "@aws-sdk/node-config-provider": "3.347.0",
24
+ "@aws-sdk/types": "3.347.0",
25
25
  "tslib": "^2.5.0"
26
26
  },
27
27
  "devDependencies": {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@aws-sdk/util-waiter",
3
- "version": "3.342.0",
3
+ "version": "3.347.0",
4
4
  "description": "Shared utilities for client waiters for the AWS SDK",
5
5
  "dependencies": {
6
- "@aws-sdk/abort-controller": "3.342.0",
7
- "@aws-sdk/types": "3.342.0",
6
+ "@aws-sdk/abort-controller": "3.347.0",
7
+ "@aws-sdk/types": "3.347.0",
8
8
  "tslib": "^2.5.0"
9
9
  },
10
10
  "scripts": {
@@ -1,5 +1,31 @@
1
1
  Note: If you find missing information about particular minor version, that version must have been changed without any functional change in this library.
2
2
 
3
+ **4.2.4 / 2023-06-06**
4
+ * fix security bug
5
+
6
+ **4.2.3 / 2023-06-05**
7
+ * fix security bug
8
+
9
+ **4.2.2 / 2023-04-18**
10
+ * fix #562: fix unpaired tag when it comes in last of a nested tag. Also throw error when unpaired tag is used as closing tag
11
+
12
+ **4.2.1 / 2023-04-18**
13
+ * fix: jpath after unpaired tags
14
+
15
+ **4.2.0 / 2023-04-09**
16
+ * support `updateTag` parser property
17
+
18
+ **4.1.4 / 2023-04-08**
19
+ * update typings to let user create XMLBuilder instance without options (#556) (By [Patrick](https://github.com/omggga))
20
+ * fix: IsArray option isn't parsing tags with 0 as value correctly #490 (#557) (By [Aleksandr Murashkin](https://github.com/p-kuen))
21
+ * feature: support `oneListGroup` to group repeated children tags udder single group
22
+
23
+ **4.1.3 / 2023-02-26**
24
+ * fix #546: Support complex entity value
25
+
26
+ **4.1.2 / 2023-02-12**
27
+ * Security Fix
28
+
3
29
  **4.1.1 / 2023-02-03**
4
30
  * Fix #540: ignoreAttributes breaks unpairedTags
5
31
  * Refactor XML builder code
@@ -54,6 +54,7 @@ Check [ThankYouBackers](https://github.com/NaturalIntelligence/ThankYouBackers)
54
54
  <a href="http://www.magento.com/" title="Magento" > <img src="https://avatars2.githubusercontent.com/u/168457" width="60px" ></a>
55
55
  <a href="https://github.com/SAP" title="SAP" > <img src="https://user-images.githubusercontent.com/7692328/204835214-d9d25b58-e3df-408d-87a3-c7d36b578ee4.png" width="60px" ></a>
56
56
  <a href="https://github.com/postmanlabs" title="postman" > <img src="https://user-images.githubusercontent.com/7692328/204835529-e9e290ad-696a-49ad-9d34-08e955704715.png" width="60px" ></a>
57
+ <a href="https://github.com/react-native-community" title="React Native Community" > <img src="https://avatars.githubusercontent.com/u/20269980?v=4" width="60px" ></a>
57
58
 
58
59
  Check the list of all known users [here](./USERs.md);
59
60
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-xml-parser",
3
- "version": "4.1.2",
3
+ "version": "4.2.4",
4
4
  "description": "Validate XML, Parse XML, Build XML without C/C++ based libraries",
5
5
  "main": "./src/fxp.js",
6
6
  "scripts": {
@@ -53,15 +53,18 @@
53
53
  "jasmine": "^3.6.4",
54
54
  "nyc": "^15.1.0",
55
55
  "prettier": "^1.19.1",
56
- "publish-please": "^2.4.1",
56
+ "publish-please": "^5.5.2",
57
57
  "webpack": "^5.64.4",
58
58
  "webpack-cli": "^4.9.1"
59
59
  },
60
60
  "typings": "src/fxp.d.ts",
61
- "funding": {
61
+ "funding": [{
62
62
  "type": "paypal",
63
63
  "url": "https://paypal.me/naturalintelligence"
64
- },
64
+ },{
65
+ "type": "github",
66
+ "url": "https://github.com/sponsors/NaturalIntelligence"
67
+ }],
65
68
  "dependencies": {
66
69
  "strnum": "^1.0.5"
67
70
  }
@@ -32,6 +32,14 @@ Control how tag value should be parsed. Called only if tag value is not empty
32
32
  ignorePiTags: boolean;
33
33
  transformTagName: ((tagName: string) => string) | false;
34
34
  transformAttributeName: ((attributeName: string) => string) | false;
35
+ /**
36
+ Change the tag name when a different name is returned. Skip the tag from parsed result when false is returned.
37
+ Modify `attrs` object to control attributes for the given tag.
38
+
39
+ @returns {string} new tag name.
40
+ @returns false to skip the tag
41
+ */
42
+ updateTag: (tagName: string, jPath: string, attrs: {[k: string]: string}) => string | boolean;
35
43
  };
36
44
  type strnumOptions = {
37
45
  hex: boolean;
@@ -65,6 +73,7 @@ type XmlBuilderOptions = {
65
73
  tagValueProcessor: (name: string, value: unknown) => string;
66
74
  attributeValueProcessor: (name: string, value: unknown) => string;
67
75
  processEntities: boolean;
76
+ oneListGroup: boolean;
68
77
  };
69
78
  type XmlBuilderOptionsOptional = Partial<XmlBuilderOptions>;
70
79
 
@@ -94,6 +103,6 @@ export class XMLValidator{
94
103
  static validate( xmlData: string, options?: validationOptionsOptional): true | ValidationError;
95
104
  }
96
105
  export class XMLBuilder {
97
- constructor(options: XmlBuilderOptionsOptional);
106
+ constructor(options?: XmlBuilderOptionsOptional);
98
107
  build(jObj: any): any;
99
108
  }
@@ -33,6 +33,7 @@ const defaultOptions = {
33
33
  stopNodes: [],
34
34
  // transformTagName: false,
35
35
  // transformAttributeName: false,
36
+ oneListGroup: false
36
37
  };
37
38
 
38
39
  function Builder(options) {
@@ -103,6 +104,7 @@ Builder.prototype.j2x = function(jObj, level) {
103
104
  } else if (Array.isArray(jObj[key])) {
104
105
  //repeated nodes
105
106
  const arrLen = jObj[key].length;
107
+ let listTagVal = "";
106
108
  for (let j = 0; j < arrLen; j++) {
107
109
  const item = jObj[key][j];
108
110
  if (typeof item === 'undefined') {
@@ -112,11 +114,19 @@ Builder.prototype.j2x = function(jObj, level) {
112
114
  else val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
113
115
  // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;
114
116
  } else if (typeof item === 'object') {
115
- val += this.processTextOrObjNode(item, key, level)
117
+ if(this.options.oneListGroup ){
118
+ listTagVal += this.j2x(item, level + 1).val;
119
+ }else{
120
+ listTagVal += this.processTextOrObjNode(item, key, level)
121
+ }
116
122
  } else {
117
- val += this.buildTextValNode(item, key, '', level);
123
+ listTagVal += this.buildTextValNode(item, key, '', level);
118
124
  }
119
125
  }
126
+ if(this.options.oneListGroup){
127
+ listTagVal = this.buildObjectNode(listTagVal, key, '', level);
128
+ }
129
+ val += listTagVal;
120
130
  } else {
121
131
  //nested node
122
132
  if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
@@ -11,80 +11,34 @@ function readDocType(xmlData, i){
11
11
  {
12
12
  i = i+9;
13
13
  let angleBracketsCount = 1;
14
- let hasBody = false, entity = false, comment = false;
14
+ let hasBody = false, comment = false;
15
15
  let exp = "";
16
16
  for(;i<xmlData.length;i++){
17
- if (xmlData[i] === '<' && !comment) {
18
- if( hasBody &&
19
- xmlData[i+1] === '!' &&
20
- xmlData[i+2] === 'E' &&
21
- xmlData[i+3] === 'N' &&
22
- xmlData[i+4] === 'T' &&
23
- xmlData[i+5] === 'I' &&
24
- xmlData[i+6] === 'T' &&
25
- xmlData[i+7] === 'Y'
26
- ){
27
- i += 7;
28
- entity = true;
29
- }else if( hasBody &&
30
- xmlData[i+1] === '!' &&
31
- xmlData[i+2] === 'E' &&
32
- xmlData[i+3] === 'L' &&
33
- xmlData[i+4] === 'E' &&
34
- xmlData[i+5] === 'M' &&
35
- xmlData[i+6] === 'E' &&
36
- xmlData[i+7] === 'N' &&
37
- xmlData[i+8] === 'T'
38
- ){
39
- //Not supported
40
- i += 8;
41
- }else if( hasBody &&
42
- xmlData[i+1] === '!' &&
43
- xmlData[i+2] === 'A' &&
44
- xmlData[i+3] === 'T' &&
45
- xmlData[i+4] === 'T' &&
46
- xmlData[i+5] === 'L' &&
47
- xmlData[i+6] === 'I' &&
48
- xmlData[i+7] === 'S' &&
49
- xmlData[i+8] === 'T'
50
- ){
51
- //Not supported
52
- i += 8;
53
- }else if( hasBody &&
54
- xmlData[i+1] === '!' &&
55
- xmlData[i+2] === 'N' &&
56
- xmlData[i+3] === 'O' &&
57
- xmlData[i+4] === 'T' &&
58
- xmlData[i+5] === 'A' &&
59
- xmlData[i+6] === 'T' &&
60
- xmlData[i+7] === 'I' &&
61
- xmlData[i+8] === 'O' &&
62
- xmlData[i+9] === 'N'
63
- ){
64
- //Not supported
65
- i += 9;
66
- }else if( //comment
67
- xmlData[i+1] === '!' &&
68
- xmlData[i+2] === '-' &&
69
- xmlData[i+3] === '-'
70
- ){
71
- comment = true;
72
- }else{
73
- throw new Error("Invalid DOCTYPE");
17
+ if (xmlData[i] === '<' && !comment) { //Determine the tag type
18
+ if( hasBody && isEntity(xmlData, i)){
19
+ i += 7;
20
+ [entityName, val,i] = readEntityExp(xmlData,i+1);
21
+ if(val.indexOf("&") === -1) //Parameter entities are not supported
22
+ entities[ validateEntityName(entityName) ] = {
23
+ regx : RegExp( `&${entityName};`,"g"),
24
+ val: val
25
+ };
74
26
  }
27
+ else if( hasBody && isElement(xmlData, i)) i += 8;//Not supported
28
+ else if( hasBody && isAttlist(xmlData, i)) i += 8;//Not supported
29
+ else if( hasBody && isNotation(xmlData, i)) i += 9;//Not supported
30
+ else if( isComment) comment = true;
31
+ else throw new Error("Invalid DOCTYPE");
32
+
75
33
  angleBracketsCount++;
76
34
  exp = "";
77
- } else if (xmlData[i] === '>') {
35
+ } else if (xmlData[i] === '>') { //Read tag content
78
36
  if(comment){
79
37
  if( xmlData[i - 1] === "-" && xmlData[i - 2] === "-"){
80
38
  comment = false;
81
39
  angleBracketsCount--;
82
40
  }
83
41
  }else{
84
- if(entity) {
85
- parseEntityExp(exp, entities);
86
- entity = false;
87
- }
88
42
  angleBracketsCount--;
89
43
  }
90
44
  if (angleBracketsCount === 0) {
@@ -105,14 +59,97 @@ function readDocType(xmlData, i){
105
59
  return {entities, i};
106
60
  }
107
61
 
108
- const entityRegex = RegExp("^\\s([a-zA-z0-0]+)[ \t](['\"])([^&]+)\\2");
109
- function parseEntityExp(exp, entities){
110
- const match = entityRegex.exec(exp);
111
- if(match){
112
- entities[ match[1] ] = {
113
- regx : RegExp( `&${match[1]};`,"g"),
114
- val: match[3]
115
- };
62
+ function readEntityExp(xmlData,i){
63
+ //External entities are not supported
64
+ // <!ENTITY ext SYSTEM "http://normal-website.com" >
65
+
66
+ //Parameter entities are not supported
67
+ // <!ENTITY entityname "&anotherElement;">
68
+
69
+ //Internal entities are supported
70
+ // <!ENTITY entityname "replacement text">
71
+
72
+ //read EntityName
73
+ let entityName = "";
74
+ for (; i < xmlData.length && (xmlData[i] !== "'" && xmlData[i] !== '"' ); i++) {
75
+ // if(xmlData[i] === " ") continue;
76
+ // else
77
+ entityName += xmlData[i];
78
+ }
79
+ entityName = entityName.trim();
80
+ if(entityName.indexOf(" ") !== -1) throw new Error("External entites are not supported");
81
+
82
+ //read Entity Value
83
+ const startChar = xmlData[i++];
84
+ let val = ""
85
+ for (; i < xmlData.length && xmlData[i] !== startChar ; i++) {
86
+ val += xmlData[i];
87
+ }
88
+ return [entityName, val, i];
89
+ }
90
+
91
+ function isComment(xmlData, i){
92
+ if(xmlData[i+1] === '!' &&
93
+ xmlData[i+2] === '-' &&
94
+ xmlData[i+3] === '-') return true
95
+ return false
96
+ }
97
+ function isEntity(xmlData, i){
98
+ if(xmlData[i+1] === '!' &&
99
+ xmlData[i+2] === 'E' &&
100
+ xmlData[i+3] === 'N' &&
101
+ xmlData[i+4] === 'T' &&
102
+ xmlData[i+5] === 'I' &&
103
+ xmlData[i+6] === 'T' &&
104
+ xmlData[i+7] === 'Y') return true
105
+ return false
106
+ }
107
+ function isElement(xmlData, i){
108
+ if(xmlData[i+1] === '!' &&
109
+ xmlData[i+2] === 'E' &&
110
+ xmlData[i+3] === 'L' &&
111
+ xmlData[i+4] === 'E' &&
112
+ xmlData[i+5] === 'M' &&
113
+ xmlData[i+6] === 'E' &&
114
+ xmlData[i+7] === 'N' &&
115
+ xmlData[i+8] === 'T') return true
116
+ return false
117
+ }
118
+
119
+ function isAttlist(xmlData, i){
120
+ if(xmlData[i+1] === '!' &&
121
+ xmlData[i+2] === 'A' &&
122
+ xmlData[i+3] === 'T' &&
123
+ xmlData[i+4] === 'T' &&
124
+ xmlData[i+5] === 'L' &&
125
+ xmlData[i+6] === 'I' &&
126
+ xmlData[i+7] === 'S' &&
127
+ xmlData[i+8] === 'T') return true
128
+ return false
129
+ }
130
+ function isNotation(xmlData, i){
131
+ if(xmlData[i+1] === '!' &&
132
+ xmlData[i+2] === 'N' &&
133
+ xmlData[i+3] === 'O' &&
134
+ xmlData[i+4] === 'T' &&
135
+ xmlData[i+5] === 'A' &&
136
+ xmlData[i+6] === 'T' &&
137
+ xmlData[i+7] === 'I' &&
138
+ xmlData[i+8] === 'O' &&
139
+ xmlData[i+9] === 'N') return true
140
+ return false
141
+ }
142
+
143
+ //an entity name should not contains special characters that may be used in regex
144
+ //Eg !?\\\/[]$%{}^&*()<>
145
+ const specialChar = "!?\\\/[]$%{}^&*()<>|+";
146
+
147
+ function validateEntityName(name){
148
+ for (let i = 0; i < specialChar.length; i++) {
149
+ const ch = specialChar[i];
150
+ if(name.indexOf(ch) !== -1) throw new Error(`Invalid character ${ch} in entity name`);
116
151
  }
152
+ return name;
117
153
  }
154
+
118
155
  module.exports = readDocType;
@@ -34,6 +34,10 @@ const defaultOptions = {
34
34
  ignorePiTags: false,
35
35
  transformTagName: false,
36
36
  transformAttributeName: false,
37
+ updateTag: function(tagName, jPath, attrs){
38
+ return tagName
39
+ },
40
+ // skipEmptyListItem: false
37
41
  };
38
42
 
39
43
  const buildOptions = function(options) {
@@ -50,6 +50,7 @@ class OrderedObjParser{
50
50
  this.replaceEntitiesValue = replaceEntitiesValue;
51
51
  this.readStopNodeData = readStopNodeData;
52
52
  this.saveTextToParentTag = saveTextToParentTag;
53
+ this.addChild = addChild;
53
54
  }
54
55
 
55
56
  }
@@ -121,7 +122,7 @@ function resolveNameSpace(tagname) {
121
122
  //const attrsRegx = new RegExp("([\\w\\-\\.\\:]+)\\s*=\\s*(['\"])((.|\n)*?)\\2","gm");
122
123
  const attrsRegx = new RegExp('([^\\s=]+)\\s*(=\\s*([\'"])([\\s\\S]*?)\\3)?', 'gm');
123
124
 
124
- function buildAttributesMap(attrStr, jPath) {
125
+ function buildAttributesMap(attrStr, jPath, tagName) {
125
126
  if (!this.options.ignoreAttributes && typeof attrStr === 'string') {
126
127
  // attrStr = attrStr.replace(/\r?\n/g, ' ');
127
128
  //attrStr = attrStr || attrStr.trim();
@@ -171,7 +172,7 @@ function buildAttributesMap(attrStr, jPath) {
171
172
  attrCollection[this.options.attributesGroupName] = attrs;
172
173
  return attrCollection;
173
174
  }
174
- return attrs;
175
+ return attrs
175
176
  }
176
177
  }
177
178
 
@@ -205,9 +206,21 @@ const parseXml = function(xmlData) {
205
206
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
206
207
  }
207
208
 
208
- jPath = jPath.substr(0, jPath.lastIndexOf("."));
209
-
210
- currentNode = this.tagsNodeStack.pop();//avoid recurssion, set the parent tag scope
209
+ //check if last tag of nested tag was unpaired tag
210
+ const lastTagName = jPath.substring(jPath.lastIndexOf(".")+1);
211
+ if(tagName && this.options.unpairedTags.indexOf(tagName) !== -1 ){
212
+ throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
213
+ }
214
+ let propIndex = 0
215
+ if(lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1 ){
216
+ propIndex = jPath.lastIndexOf('.', jPath.lastIndexOf('.')-1)
217
+ this.tagsNodeStack.pop();
218
+ }else{
219
+ propIndex = jPath.lastIndexOf(".");
220
+ }
221
+ jPath = jPath.substring(0, propIndex);
222
+
223
+ currentNode = this.tagsNodeStack.pop();//avoid recursion, set the parent tag scope
211
224
  textData = "";
212
225
  i = closeIndex;
213
226
  } else if( xmlData[i+1] === '?') {
@@ -224,9 +237,9 @@ const parseXml = function(xmlData) {
224
237
  childNode.add(this.options.textNodeName, "");
225
238
 
226
239
  if(tagData.tagName !== tagData.tagExp && tagData.attrExpPresent){
227
- childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath);
240
+ childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
228
241
  }
229
- currentNode.addChild(childNode);
242
+ this.addChild(currentNode, childNode, jPath)
230
243
 
231
244
  }
232
245
 
@@ -283,23 +296,22 @@ const parseXml = function(xmlData) {
283
296
  }
284
297
  }
285
298
 
286
- if(tagName !== xmlObj.tagname){
287
- jPath += jPath ? "." + tagName : tagName;
288
- }
289
-
290
299
  //check if last tag was unpaired tag
291
300
  const lastTag = currentNode;
292
301
  if(lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1 ){
293
302
  currentNode = this.tagsNodeStack.pop();
303
+ jPath = jPath.substring(0, jPath.lastIndexOf("."));
304
+ }
305
+ if(tagName !== xmlObj.tagname){
306
+ jPath += jPath ? "." + tagName : tagName;
294
307
  }
295
-
296
308
  if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) { //TODO: namespace
297
309
  let tagContent = "";
298
310
  //self-closing tag
299
311
  if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){
300
312
  i = result.closeIndex;
301
313
  }
302
- //boolean tag
314
+ //unpaired tag
303
315
  else if(this.options.unpairedTags.indexOf(tagName) !== -1){
304
316
  i = result.closeIndex;
305
317
  }
@@ -314,7 +326,7 @@ const parseXml = function(xmlData) {
314
326
 
315
327
  const childNode = new xmlNode(tagName);
316
328
  if(tagName !== tagExp && attrExpPresent){
317
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
329
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
318
330
  }
319
331
  if(tagContent) {
320
332
  tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);
@@ -323,7 +335,7 @@ const parseXml = function(xmlData) {
323
335
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
324
336
  childNode.add(this.options.textNodeName, tagContent);
325
337
 
326
- currentNode.addChild(childNode);
338
+ this.addChild(currentNode, childNode, jPath)
327
339
  }else{
328
340
  //selfClosing tag
329
341
  if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){
@@ -340,10 +352,10 @@ const parseXml = function(xmlData) {
340
352
 
341
353
  const childNode = new xmlNode(tagName);
342
354
  if(tagName !== tagExp && attrExpPresent){
343
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
355
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
344
356
  }
357
+ this.addChild(currentNode, childNode, jPath)
345
358
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
346
- currentNode.addChild(childNode);
347
359
  }
348
360
  //opening tag
349
361
  else{
@@ -351,9 +363,9 @@ const parseXml = function(xmlData) {
351
363
  this.tagsNodeStack.push(currentNode);
352
364
 
353
365
  if(tagName !== tagExp && attrExpPresent){
354
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
366
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
355
367
  }
356
- currentNode.addChild(childNode);
368
+ this.addChild(currentNode, childNode, jPath)
357
369
  currentNode = childNode;
358
370
  }
359
371
  textData = "";
@@ -367,6 +379,17 @@ const parseXml = function(xmlData) {
367
379
  return xmlObj.child;
368
380
  }
369
381
 
382
+ function addChild(currentNode, childNode, jPath){
383
+ const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"])
384
+ if(result === false){
385
+ }else if(typeof result === "string"){
386
+ childNode.tagname = result
387
+ currentNode.addChild(childNode);
388
+ }else{
389
+ currentNode.addChild(childNode);
390
+ }
391
+ }
392
+
370
393
  const replaceEntitiesValue = function(val){
371
394
 
372
395
  if(this.options.processEntities){
@@ -423,7 +446,7 @@ function isItStopNode(stopNodes, jPath, currentTagName){
423
446
  }
424
447
 
425
448
  /**
426
- * Returns the tag Expression and where it is ending handling single-dobule quotes situation
449
+ * Returns the tag Expression and where it is ending handling single-double quotes situation
427
450
  * @param {string} xmlData
428
451
  * @param {number} i starting index
429
452
  * @returns
@@ -94,8 +94,20 @@ function assignAttributes(obj, attrMap, jpath, options){
94
94
  }
95
95
 
96
96
  function isLeafTag(obj, options){
97
+ const { textNodeName } = options;
97
98
  const propCount = Object.keys(obj).length;
98
- if( propCount === 0 || (propCount === 1 && obj[options.textNodeName]) ) return true;
99
+
100
+ if (propCount === 0) {
101
+ return true;
102
+ }
103
+
104
+ if (
105
+ propCount === 1 &&
106
+ (obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)
107
+ ) {
108
+ return true;
109
+ }
110
+
99
111
  return false;
100
112
  }
101
113
  exports.prettify = prettify;
package/package.json CHANGED
@@ -68,7 +68,7 @@
68
68
  "devDependencies": {
69
69
  "@aws-cdk/aws-synthetics-alpha": "2.71.0-alpha.0",
70
70
  "@aws-cdk/integ-tests-alpha": "2.71.0-alpha.0",
71
- "@types/aws-lambda": "^8.10.115",
71
+ "@types/aws-lambda": "^8.10.116",
72
72
  "@types/jest": "^27",
73
73
  "@types/lambda-tester": "^3.6.2",
74
74
  "@types/node": "^16",
@@ -78,7 +78,7 @@
78
78
  "aws-cdk-lib": "2.71.0",
79
79
  "aws-sdk-client-mock": "^2.1.1",
80
80
  "aws-sdk-client-mock-jest": "^2.1.1",
81
- "cdk-nag": "^2.27.28",
81
+ "cdk-nag": "^2.27.30",
82
82
  "constructs": "10.0.5",
83
83
  "esbuild": "^0.17.19",
84
84
  "eslint": "^8",
@@ -88,12 +88,12 @@
88
88
  "jest": "^27",
89
89
  "jest-junit": "^15",
90
90
  "jsii": "1.x",
91
- "jsii-diff": "^1.82.0",
91
+ "jsii-diff": "^1.83.0",
92
92
  "jsii-docgen": "^7.2.9",
93
- "jsii-pacmak": "^1.82.0",
93
+ "jsii-pacmak": "^1.83.0",
94
94
  "lambda-tester": "^4.0.1",
95
95
  "npm-check-updates": "^16",
96
- "projen": "0.71.82",
96
+ "projen": "0.71.85",
97
97
  "standard-version": "^9",
98
98
  "ts-jest": "^27",
99
99
  "ts-node": "^10.9.1",
@@ -105,7 +105,7 @@
105
105
  "constructs": "^10.0.5"
106
106
  },
107
107
  "dependencies": {
108
- "@aws-sdk/client-codedeploy": "^3.345.0",
108
+ "@aws-sdk/client-codedeploy": "^3.347.1",
109
109
  "jmespath": "^0.16.0"
110
110
  },
111
111
  "bundledDependencies": [
@@ -127,7 +127,7 @@
127
127
  "publishConfig": {
128
128
  "access": "public"
129
129
  },
130
- "version": "0.0.179",
130
+ "version": "0.0.181",
131
131
  "jest": {
132
132
  "testMatch": [
133
133
  "<rootDir>/src/**/__tests__/**/*.ts?(x)",