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 <[email protected]>
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];

0 commit comments

Comments
 (0)