Skip to content

Commit fd6b7eb

Browse files
trivikrpauldraper
andauthored
fix(clients): call decode from HTML entities in XML parser (#2381)
Co-authored-by: Paul Draper <paulddraper@gmail.com>
1 parent 7b32494 commit fd6b7eb

File tree

55 files changed

+86
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+86
-248
lines changed

clients/client-auto-scaling/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"@aws-sdk/util-utf8-browser": "3.13.1",
5757
"@aws-sdk/util-utf8-node": "3.13.1",
5858
"@aws-sdk/util-waiter": "3.15.0",
59+
"entities": "2.2.0",
5960
"fast-xml-parser": "3.19.0",
6061
"tslib": "^2.0.0"
6162
},

clients/client-auto-scaling/protocols/Aws_query.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ import {
342342
ResponseMetadata as __ResponseMetadata,
343343
SerdeContext as __SerdeContext,
344344
} from "@aws-sdk/types";
345+
import { decodeHTML } from "entities";
345346
import { parse as xmlParse } from "fast-xml-parser";
346347

347348
export const serializeAws_queryAttachInstancesCommand = async (
@@ -9378,14 +9379,6 @@ const buildHttpRpcRequest = async (
93789379
return new __HttpRequest(contents);
93799380
};
93809381

9381-
const decodeEscapedXML = (str: string) =>
9382-
str
9383-
.replace(/&amp;/g, "&")
9384-
.replace(/&apos;/g, "'")
9385-
.replace(/&quot;/g, '"')
9386-
.replace(/&gt;/g, ">")
9387-
.replace(/&lt;/g, "<");
9388-
93899382
const parseBody = (streamBody: any, context: __SerdeContext): any =>
93909383
collectBodyString(streamBody, context).then((encoded) => {
93919384
if (encoded.length) {
@@ -9394,7 +9387,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
93949387
ignoreAttributes: false,
93959388
parseNodeValue: false,
93969389
trimValues: false,
9397-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
9390+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
93989391
});
93999392
const textNodeName = "#text";
94009393
const key = Object.keys(parsedObj)[0];

clients/client-cloudformation/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"@aws-sdk/util-utf8-browser": "3.13.1",
5757
"@aws-sdk/util-utf8-node": "3.13.1",
5858
"@aws-sdk/util-waiter": "3.15.0",
59+
"entities": "2.2.0",
5960
"fast-xml-parser": "3.19.0",
6061
"tslib": "^2.0.0",
6162
"uuid": "^8.3.2"

clients/client-cloudformation/protocols/Aws_query.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ import {
317317
ResponseMetadata as __ResponseMetadata,
318318
SerdeContext as __SerdeContext,
319319
} from "@aws-sdk/types";
320+
import { decodeHTML } from "entities";
320321
import { parse as xmlParse } from "fast-xml-parser";
321322
import { v4 as generateIdempotencyToken } from "uuid";
322323

@@ -9645,14 +9646,6 @@ const buildHttpRpcRequest = async (
96459646
return new __HttpRequest(contents);
96469647
};
96479648

9648-
const decodeEscapedXML = (str: string) =>
9649-
str
9650-
.replace(/&amp;/g, "&")
9651-
.replace(/&apos;/g, "'")
9652-
.replace(/&quot;/g, '"')
9653-
.replace(/&gt;/g, ">")
9654-
.replace(/&lt;/g, "<");
9655-
96569649
const parseBody = (streamBody: any, context: __SerdeContext): any =>
96579650
collectBodyString(streamBody, context).then((encoded) => {
96589651
if (encoded.length) {
@@ -9661,7 +9654,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
96619654
ignoreAttributes: false,
96629655
parseNodeValue: false,
96639656
trimValues: false,
9664-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
9657+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
96659658
});
96669659
const textNodeName = "#text";
96679660
const key = Object.keys(parsedObj)[0];

clients/client-cloudfront/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"@aws-sdk/util-utf8-node": "3.13.1",
5858
"@aws-sdk/util-waiter": "3.15.0",
5959
"@aws-sdk/xml-builder": "3.14.0",
60+
"entities": "2.2.0",
6061
"fast-xml-parser": "3.19.0",
6162
"tslib": "^2.0.0"
6263
},

clients/client-cloudfront/protocols/Aws_restXml.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ import {
486486
SerdeContext as __SerdeContext,
487487
} from "@aws-sdk/types";
488488
import { XmlNode as __XmlNode, XmlText as __XmlText } from "@aws-sdk/xml-builder";
489+
import { decodeHTML } from "entities";
489490
import { parse as xmlParse } from "fast-xml-parser";
490491

491492
export const serializeAws_restXmlCreateCachePolicyCommand = async (
@@ -18584,14 +18585,6 @@ const isSerializableHeaderValue = (value: any): boolean =>
1858418585
(!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
1858518586
(!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
1858618587

18587-
const decodeEscapedXML = (str: string) =>
18588-
str
18589-
.replace(/&amp;/g, "&")
18590-
.replace(/&apos;/g, "'")
18591-
.replace(/&quot;/g, '"')
18592-
.replace(/&gt;/g, ">")
18593-
.replace(/&lt;/g, "<");
18594-
1859518588
const parseBody = (streamBody: any, context: __SerdeContext): any =>
1859618589
collectBodyString(streamBody, context).then((encoded) => {
1859718590
if (encoded.length) {
@@ -18600,7 +18593,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1860018593
ignoreAttributes: false,
1860118594
parseNodeValue: false,
1860218595
trimValues: false,
18603-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
18596+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
1860418597
});
1860518598
const textNodeName = "#text";
1860618599
const key = Object.keys(parsedObj)[0];

clients/client-cloudsearch/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"@aws-sdk/util-user-agent-node": "3.15.0",
5656
"@aws-sdk/util-utf8-browser": "3.13.1",
5757
"@aws-sdk/util-utf8-node": "3.13.1",
58+
"entities": "2.2.0",
5859
"fast-xml-parser": "3.19.0",
5960
"tslib": "^2.0.0"
6061
},

clients/client-cloudsearch/protocols/Aws_query.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ import {
168168
ResponseMetadata as __ResponseMetadata,
169169
SerdeContext as __SerdeContext,
170170
} from "@aws-sdk/types";
171+
import { decodeHTML } from "entities";
171172
import { parse as xmlParse } from "fast-xml-parser";
172173

173174
export const serializeAws_queryBuildSuggestersCommand = async (
@@ -4860,14 +4861,6 @@ const buildHttpRpcRequest = async (
48604861
return new __HttpRequest(contents);
48614862
};
48624863

4863-
const decodeEscapedXML = (str: string) =>
4864-
str
4865-
.replace(/&amp;/g, "&")
4866-
.replace(/&apos;/g, "'")
4867-
.replace(/&quot;/g, '"')
4868-
.replace(/&gt;/g, ">")
4869-
.replace(/&lt;/g, "<");
4870-
48714864
const parseBody = (streamBody: any, context: __SerdeContext): any =>
48724865
collectBodyString(streamBody, context).then((encoded) => {
48734866
if (encoded.length) {
@@ -4876,7 +4869,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
48764869
ignoreAttributes: false,
48774870
parseNodeValue: false,
48784871
trimValues: false,
4879-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
4872+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
48804873
});
48814874
const textNodeName = "#text";
48824875
const key = Object.keys(parsedObj)[0];

clients/client-cloudwatch/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"@aws-sdk/util-utf8-browser": "3.13.1",
5757
"@aws-sdk/util-utf8-node": "3.13.1",
5858
"@aws-sdk/util-waiter": "3.15.0",
59+
"entities": "2.2.0",
5960
"fast-xml-parser": "3.19.0",
6061
"tslib": "^2.0.0"
6162
},

clients/client-cloudwatch/protocols/Aws_query.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ import {
190190
ResponseMetadata as __ResponseMetadata,
191191
SerdeContext as __SerdeContext,
192192
} from "@aws-sdk/types";
193+
import { decodeHTML } from "entities";
193194
import { parse as xmlParse } from "fast-xml-parser";
194195

195196
export const serializeAws_queryDeleteAlarmsCommand = async (
@@ -6351,14 +6352,6 @@ const buildHttpRpcRequest = async (
63516352
return new __HttpRequest(contents);
63526353
};
63536354

6354-
const decodeEscapedXML = (str: string) =>
6355-
str
6356-
.replace(/&amp;/g, "&")
6357-
.replace(/&apos;/g, "'")
6358-
.replace(/&quot;/g, '"')
6359-
.replace(/&gt;/g, ">")
6360-
.replace(/&lt;/g, "<");
6361-
63626355
const parseBody = (streamBody: any, context: __SerdeContext): any =>
63636356
collectBodyString(streamBody, context).then((encoded) => {
63646357
if (encoded.length) {
@@ -6367,7 +6360,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
63676360
ignoreAttributes: false,
63686361
parseNodeValue: false,
63696362
trimValues: false,
6370-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
6363+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
63716364
});
63726365
const textNodeName = "#text";
63736366
const key = Object.keys(parsedObj)[0];

clients/client-docdb/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"@aws-sdk/util-utf8-browser": "3.13.1",
5858
"@aws-sdk/util-utf8-node": "3.13.1",
5959
"@aws-sdk/util-waiter": "3.15.0",
60+
"entities": "2.2.0",
6061
"fast-xml-parser": "3.19.0",
6162
"tslib": "^2.0.0"
6263
},

clients/client-docdb/protocols/Aws_query.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ import {
295295
ResponseMetadata as __ResponseMetadata,
296296
SerdeContext as __SerdeContext,
297297
} from "@aws-sdk/types";
298+
import { decodeHTML } from "entities";
298299
import { parse as xmlParse } from "fast-xml-parser";
299300

300301
export const serializeAws_queryAddTagsToResourceCommand = async (
@@ -8697,14 +8698,6 @@ const buildHttpRpcRequest = async (
86978698
return new __HttpRequest(contents);
86988699
};
86998700

8700-
const decodeEscapedXML = (str: string) =>
8701-
str
8702-
.replace(/&amp;/g, "&")
8703-
.replace(/&apos;/g, "'")
8704-
.replace(/&quot;/g, '"')
8705-
.replace(/&gt;/g, ">")
8706-
.replace(/&lt;/g, "<");
8707-
87088701
const parseBody = (streamBody: any, context: __SerdeContext): any =>
87098702
collectBodyString(streamBody, context).then((encoded) => {
87108703
if (encoded.length) {
@@ -8713,7 +8706,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
87138706
ignoreAttributes: false,
87148707
parseNodeValue: false,
87158708
trimValues: false,
8716-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
8709+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
87178710
});
87188711
const textNodeName = "#text";
87198712
const key = Object.keys(parsedObj)[0];

clients/client-ec2/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"@aws-sdk/util-utf8-browser": "3.13.1",
5858
"@aws-sdk/util-utf8-node": "3.13.1",
5959
"@aws-sdk/util-waiter": "3.15.0",
60+
"entities": "2.2.0",
6061
"fast-xml-parser": "3.19.0",
6162
"tslib": "^2.0.0",
6263
"uuid": "^8.3.2"

clients/client-ec2/protocols/Aws_ec2.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,6 +2896,7 @@ import {
28962896
ResponseMetadata as __ResponseMetadata,
28972897
SerdeContext as __SerdeContext,
28982898
} from "@aws-sdk/types";
2899+
import { decodeHTML } from "entities";
28992900
import { parse as xmlParse } from "fast-xml-parser";
29002901
import { v4 as generateIdempotencyToken } from "uuid";
29012902

@@ -71681,14 +71682,6 @@ const buildHttpRpcRequest = async (
7168171682
return new __HttpRequest(contents);
7168271683
};
7168371684

71684-
const decodeEscapedXML = (str: string) =>
71685-
str
71686-
.replace(/&amp;/g, "&")
71687-
.replace(/&apos;/g, "'")
71688-
.replace(/&quot;/g, '"')
71689-
.replace(/&gt;/g, ">")
71690-
.replace(/&lt;/g, "<");
71691-
7169271685
const parseBody = (streamBody: any, context: __SerdeContext): any =>
7169371686
collectBodyString(streamBody, context).then((encoded) => {
7169471687
if (encoded.length) {
@@ -71697,7 +71690,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
7169771690
ignoreAttributes: false,
7169871691
parseNodeValue: false,
7169971692
trimValues: false,
71700-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
71693+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
7170171694
});
7170271695
const textNodeName = "#text";
7170371696
const key = Object.keys(parsedObj)[0];

clients/client-elastic-beanstalk/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"@aws-sdk/util-utf8-browser": "3.13.1",
5757
"@aws-sdk/util-utf8-node": "3.13.1",
5858
"@aws-sdk/util-waiter": "3.15.0",
59+
"entities": "2.2.0",
5960
"fast-xml-parser": "3.19.0",
6061
"tslib": "^2.0.0"
6162
},

clients/client-elastic-beanstalk/protocols/Aws_query.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ import {
325325
ResponseMetadata as __ResponseMetadata,
326326
SerdeContext as __SerdeContext,
327327
} from "@aws-sdk/types";
328+
import { decodeHTML } from "entities";
328329
import { parse as xmlParse } from "fast-xml-parser";
329330

330331
export const serializeAws_queryAbortEnvironmentUpdateCommand = async (
@@ -8194,14 +8195,6 @@ const buildHttpRpcRequest = async (
81948195
return new __HttpRequest(contents);
81958196
};
81968197

8197-
const decodeEscapedXML = (str: string) =>
8198-
str
8199-
.replace(/&amp;/g, "&")
8200-
.replace(/&apos;/g, "'")
8201-
.replace(/&quot;/g, '"')
8202-
.replace(/&gt;/g, ">")
8203-
.replace(/&lt;/g, "<");
8204-
82058198
const parseBody = (streamBody: any, context: __SerdeContext): any =>
82068199
collectBodyString(streamBody, context).then((encoded) => {
82078200
if (encoded.length) {
@@ -8210,7 +8203,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
82108203
ignoreAttributes: false,
82118204
parseNodeValue: false,
82128205
trimValues: false,
8213-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
8206+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
82148207
});
82158208
const textNodeName = "#text";
82168209
const key = Object.keys(parsedObj)[0];

clients/client-elastic-load-balancing-v2/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"@aws-sdk/util-user-agent-node": "3.15.0",
5656
"@aws-sdk/util-utf8-browser": "3.13.1",
5757
"@aws-sdk/util-utf8-node": "3.13.1",
58+
"entities": "2.2.0",
5859
"fast-xml-parser": "3.19.0",
5960
"tslib": "^2.0.0"
6061
},

clients/client-elastic-load-balancing-v2/protocols/Aws_query.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ import {
226226
ResponseMetadata as __ResponseMetadata,
227227
SerdeContext as __SerdeContext,
228228
} from "@aws-sdk/types";
229+
import { decodeHTML } from "entities";
229230
import { parse as xmlParse } from "fast-xml-parser";
230231

231232
export const serializeAws_queryAddListenerCertificatesCommand = async (
@@ -7850,14 +7851,6 @@ const buildHttpRpcRequest = async (
78507851
return new __HttpRequest(contents);
78517852
};
78527853

7853-
const decodeEscapedXML = (str: string) =>
7854-
str
7855-
.replace(/&amp;/g, "&")
7856-
.replace(/&apos;/g, "'")
7857-
.replace(/&quot;/g, '"')
7858-
.replace(/&gt;/g, ">")
7859-
.replace(/&lt;/g, "<");
7860-
78617854
const parseBody = (streamBody: any, context: __SerdeContext): any =>
78627855
collectBodyString(streamBody, context).then((encoded) => {
78637856
if (encoded.length) {
@@ -7866,7 +7859,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
78667859
ignoreAttributes: false,
78677860
parseNodeValue: false,
78687861
trimValues: false,
7869-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
7862+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
78707863
});
78717864
const textNodeName = "#text";
78727865
const key = Object.keys(parsedObj)[0];

clients/client-elastic-load-balancing/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"@aws-sdk/util-utf8-browser": "3.13.1",
5757
"@aws-sdk/util-utf8-node": "3.13.1",
5858
"@aws-sdk/util-waiter": "3.15.0",
59+
"entities": "2.2.0",
5960
"fast-xml-parser": "3.19.0",
6061
"tslib": "^2.0.0"
6162
},

clients/client-elastic-load-balancing/protocols/Aws_query.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ import {
221221
ResponseMetadata as __ResponseMetadata,
222222
SerdeContext as __SerdeContext,
223223
} from "@aws-sdk/types";
224+
import { decodeHTML } from "entities";
224225
import { parse as xmlParse } from "fast-xml-parser";
225226

226227
export const serializeAws_queryAddTagsCommand = async (
@@ -5399,14 +5400,6 @@ const buildHttpRpcRequest = async (
53995400
return new __HttpRequest(contents);
54005401
};
54015402

5402-
const decodeEscapedXML = (str: string) =>
5403-
str
5404-
.replace(/&amp;/g, "&")
5405-
.replace(/&apos;/g, "'")
5406-
.replace(/&quot;/g, '"')
5407-
.replace(/&gt;/g, ">")
5408-
.replace(/&lt;/g, "<");
5409-
54105403
const parseBody = (streamBody: any, context: __SerdeContext): any =>
54115404
collectBodyString(streamBody, context).then((encoded) => {
54125405
if (encoded.length) {
@@ -5415,7 +5408,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
54155408
ignoreAttributes: false,
54165409
parseNodeValue: false,
54175410
trimValues: false,
5418-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
5411+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
54195412
});
54205413
const textNodeName = "#text";
54215414
const key = Object.keys(parsedObj)[0];

0 commit comments

Comments
 (0)