Skip to content

fix(clients): call decode from HTML entities in XML parser #2381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clients/client-auto-scaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@aws-sdk/util-utf8-browser": "3.13.1",
"@aws-sdk/util-utf8-node": "3.13.1",
"@aws-sdk/util-waiter": "3.15.0",
"entities": "2.2.0",
"fast-xml-parser": "3.19.0",
"tslib": "^2.0.0"
},
Expand Down
11 changes: 2 additions & 9 deletions clients/client-auto-scaling/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ import {
ResponseMetadata as __ResponseMetadata,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { decodeHTML } from "entities";
import { parse as xmlParse } from "fast-xml-parser";

export const serializeAws_queryAttachInstancesCommand = async (
Expand Down Expand Up @@ -9378,14 +9379,6 @@ const buildHttpRpcRequest = async (
return new __HttpRequest(contents);
};

const decodeEscapedXML = (str: string) =>
str
.replace(/&/g, "&")
.replace(/'/g, "'")
.replace(/"/g, '"')
.replace(/>/g, ">")
.replace(/&lt;/g, "<");

const parseBody = (streamBody: any, context: __SerdeContext): any =>
collectBodyString(streamBody, context).then((encoded) => {
if (encoded.length) {
Expand All @@ -9394,7 +9387,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
1 change: 1 addition & 0 deletions clients/client-cloudformation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@aws-sdk/util-utf8-browser": "3.13.1",
"@aws-sdk/util-utf8-node": "3.13.1",
"@aws-sdk/util-waiter": "3.15.0",
"entities": "2.2.0",
"fast-xml-parser": "3.19.0",
"tslib": "^2.0.0",
"uuid": "^8.3.2"
Expand Down
11 changes: 2 additions & 9 deletions clients/client-cloudformation/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ import {
ResponseMetadata as __ResponseMetadata,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { decodeHTML } from "entities";
import { parse as xmlParse } from "fast-xml-parser";
import { v4 as generateIdempotencyToken } from "uuid";

Expand Down Expand Up @@ -9645,14 +9646,6 @@ const buildHttpRpcRequest = async (
return new __HttpRequest(contents);
};

const decodeEscapedXML = (str: string) =>
str
.replace(/&amp;/g, "&")
.replace(/&apos;/g, "'")
.replace(/&quot;/g, '"')
.replace(/&gt;/g, ">")
.replace(/&lt;/g, "<");

const parseBody = (streamBody: any, context: __SerdeContext): any =>
collectBodyString(streamBody, context).then((encoded) => {
if (encoded.length) {
Expand All @@ -9661,7 +9654,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
1 change: 1 addition & 0 deletions clients/client-cloudfront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@aws-sdk/util-utf8-node": "3.13.1",
"@aws-sdk/util-waiter": "3.15.0",
"@aws-sdk/xml-builder": "3.14.0",
"entities": "2.2.0",
"fast-xml-parser": "3.19.0",
"tslib": "^2.0.0"
},
Expand Down
11 changes: 2 additions & 9 deletions clients/client-cloudfront/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ import {
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { XmlNode as __XmlNode, XmlText as __XmlText } from "@aws-sdk/xml-builder";
import { decodeHTML } from "entities";
import { parse as xmlParse } from "fast-xml-parser";

export const serializeAws_restXmlCreateCachePolicyCommand = async (
Expand Down Expand Up @@ -18506,14 +18507,6 @@ const isSerializableHeaderValue = (value: any): boolean =>
(!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
(!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);

const decodeEscapedXML = (str: string) =>
str
.replace(/&amp;/g, "&")
.replace(/&apos;/g, "'")
.replace(/&quot;/g, '"')
.replace(/&gt;/g, ">")
.replace(/&lt;/g, "<");

const parseBody = (streamBody: any, context: __SerdeContext): any =>
collectBodyString(streamBody, context).then((encoded) => {
if (encoded.length) {
Expand All @@ -18522,7 +18515,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
1 change: 1 addition & 0 deletions clients/client-cloudsearch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@aws-sdk/util-user-agent-node": "3.15.0",
"@aws-sdk/util-utf8-browser": "3.13.1",
"@aws-sdk/util-utf8-node": "3.13.1",
"entities": "2.2.0",
"fast-xml-parser": "3.19.0",
"tslib": "^2.0.0"
},
Expand Down
11 changes: 2 additions & 9 deletions clients/client-cloudsearch/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ import {
ResponseMetadata as __ResponseMetadata,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { decodeHTML } from "entities";
import { parse as xmlParse } from "fast-xml-parser";

export const serializeAws_queryBuildSuggestersCommand = async (
Expand Down Expand Up @@ -4860,14 +4861,6 @@ const buildHttpRpcRequest = async (
return new __HttpRequest(contents);
};

const decodeEscapedXML = (str: string) =>
str
.replace(/&amp;/g, "&")
.replace(/&apos;/g, "'")
.replace(/&quot;/g, '"')
.replace(/&gt;/g, ">")
.replace(/&lt;/g, "<");

const parseBody = (streamBody: any, context: __SerdeContext): any =>
collectBodyString(streamBody, context).then((encoded) => {
if (encoded.length) {
Expand All @@ -4876,7 +4869,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
1 change: 1 addition & 0 deletions clients/client-cloudwatch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@aws-sdk/util-utf8-browser": "3.13.1",
"@aws-sdk/util-utf8-node": "3.13.1",
"@aws-sdk/util-waiter": "3.15.0",
"entities": "2.2.0",
"fast-xml-parser": "3.19.0",
"tslib": "^2.0.0"
},
Expand Down
11 changes: 2 additions & 9 deletions clients/client-cloudwatch/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ import {
ResponseMetadata as __ResponseMetadata,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { decodeHTML } from "entities";
import { parse as xmlParse } from "fast-xml-parser";

export const serializeAws_queryDeleteAlarmsCommand = async (
Expand Down Expand Up @@ -6351,14 +6352,6 @@ const buildHttpRpcRequest = async (
return new __HttpRequest(contents);
};

const decodeEscapedXML = (str: string) =>
str
.replace(/&amp;/g, "&")
.replace(/&apos;/g, "'")
.replace(/&quot;/g, '"')
.replace(/&gt;/g, ">")
.replace(/&lt;/g, "<");

const parseBody = (streamBody: any, context: __SerdeContext): any =>
collectBodyString(streamBody, context).then((encoded) => {
if (encoded.length) {
Expand All @@ -6367,7 +6360,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
1 change: 1 addition & 0 deletions clients/client-docdb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@aws-sdk/util-utf8-browser": "3.13.1",
"@aws-sdk/util-utf8-node": "3.13.1",
"@aws-sdk/util-waiter": "3.15.0",
"entities": "2.2.0",
"fast-xml-parser": "3.19.0",
"tslib": "^2.0.0"
},
Expand Down
11 changes: 2 additions & 9 deletions clients/client-docdb/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ import {
ResponseMetadata as __ResponseMetadata,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { decodeHTML } from "entities";
import { parse as xmlParse } from "fast-xml-parser";

export const serializeAws_queryAddTagsToResourceCommand = async (
Expand Down Expand Up @@ -8697,14 +8698,6 @@ const buildHttpRpcRequest = async (
return new __HttpRequest(contents);
};

const decodeEscapedXML = (str: string) =>
str
.replace(/&amp;/g, "&")
.replace(/&apos;/g, "'")
.replace(/&quot;/g, '"')
.replace(/&gt;/g, ">")
.replace(/&lt;/g, "<");

const parseBody = (streamBody: any, context: __SerdeContext): any =>
collectBodyString(streamBody, context).then((encoded) => {
if (encoded.length) {
Expand All @@ -8713,7 +8706,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
1 change: 1 addition & 0 deletions clients/client-ec2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@aws-sdk/util-utf8-browser": "3.13.1",
"@aws-sdk/util-utf8-node": "3.13.1",
"@aws-sdk/util-waiter": "3.15.0",
"entities": "2.2.0",
"fast-xml-parser": "3.19.0",
"tslib": "^2.0.0",
"uuid": "^8.3.2"
Expand Down
11 changes: 2 additions & 9 deletions clients/client-ec2/protocols/Aws_ec2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2896,6 +2896,7 @@ import {
ResponseMetadata as __ResponseMetadata,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { decodeHTML } from "entities";
import { parse as xmlParse } from "fast-xml-parser";
import { v4 as generateIdempotencyToken } from "uuid";

Expand Down Expand Up @@ -71681,14 +71682,6 @@ const buildHttpRpcRequest = async (
return new __HttpRequest(contents);
};

const decodeEscapedXML = (str: string) =>
str
.replace(/&amp;/g, "&")
.replace(/&apos;/g, "'")
.replace(/&quot;/g, '"')
.replace(/&gt;/g, ">")
.replace(/&lt;/g, "<");

const parseBody = (streamBody: any, context: __SerdeContext): any =>
collectBodyString(streamBody, context).then((encoded) => {
if (encoded.length) {
Expand All @@ -71697,7 +71690,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
1 change: 1 addition & 0 deletions clients/client-elastic-beanstalk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@aws-sdk/util-utf8-browser": "3.13.1",
"@aws-sdk/util-utf8-node": "3.13.1",
"@aws-sdk/util-waiter": "3.15.0",
"entities": "2.2.0",
"fast-xml-parser": "3.19.0",
"tslib": "^2.0.0"
},
Expand Down
11 changes: 2 additions & 9 deletions clients/client-elastic-beanstalk/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ import {
ResponseMetadata as __ResponseMetadata,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { decodeHTML } from "entities";
import { parse as xmlParse } from "fast-xml-parser";

export const serializeAws_queryAbortEnvironmentUpdateCommand = async (
Expand Down Expand Up @@ -8194,14 +8195,6 @@ const buildHttpRpcRequest = async (
return new __HttpRequest(contents);
};

const decodeEscapedXML = (str: string) =>
str
.replace(/&amp;/g, "&")
.replace(/&apos;/g, "'")
.replace(/&quot;/g, '"')
.replace(/&gt;/g, ">")
.replace(/&lt;/g, "<");

const parseBody = (streamBody: any, context: __SerdeContext): any =>
collectBodyString(streamBody, context).then((encoded) => {
if (encoded.length) {
Expand All @@ -8210,7 +8203,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
1 change: 1 addition & 0 deletions clients/client-elastic-load-balancing-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@aws-sdk/util-user-agent-node": "3.15.0",
"@aws-sdk/util-utf8-browser": "3.13.1",
"@aws-sdk/util-utf8-node": "3.13.1",
"entities": "2.2.0",
"fast-xml-parser": "3.19.0",
"tslib": "^2.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ import {
ResponseMetadata as __ResponseMetadata,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { decodeHTML } from "entities";
import { parse as xmlParse } from "fast-xml-parser";

export const serializeAws_queryAddListenerCertificatesCommand = async (
Expand Down Expand Up @@ -7850,14 +7851,6 @@ const buildHttpRpcRequest = async (
return new __HttpRequest(contents);
};

const decodeEscapedXML = (str: string) =>
str
.replace(/&amp;/g, "&")
.replace(/&apos;/g, "'")
.replace(/&quot;/g, '"')
.replace(/&gt;/g, ">")
.replace(/&lt;/g, "<");

const parseBody = (streamBody: any, context: __SerdeContext): any =>
collectBodyString(streamBody, context).then((encoded) => {
if (encoded.length) {
Expand All @@ -7866,7 +7859,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
1 change: 1 addition & 0 deletions clients/client-elastic-load-balancing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@aws-sdk/util-utf8-browser": "3.13.1",
"@aws-sdk/util-utf8-node": "3.13.1",
"@aws-sdk/util-waiter": "3.15.0",
"entities": "2.2.0",
"fast-xml-parser": "3.19.0",
"tslib": "^2.0.0"
},
Expand Down
11 changes: 2 additions & 9 deletions clients/client-elastic-load-balancing/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ import {
ResponseMetadata as __ResponseMetadata,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { decodeHTML } from "entities";
import { parse as xmlParse } from "fast-xml-parser";

export const serializeAws_queryAddTagsCommand = async (
Expand Down Expand Up @@ -5399,14 +5400,6 @@ const buildHttpRpcRequest = async (
return new __HttpRequest(contents);
};

const decodeEscapedXML = (str: string) =>
str
.replace(/&amp;/g, "&")
.replace(/&apos;/g, "'")
.replace(/&quot;/g, '"')
.replace(/&gt;/g, ">")
.replace(/&lt;/g, "<");

const parseBody = (streamBody: any, context: __SerdeContext): any =>
collectBodyString(streamBody, context).then((encoded) => {
if (encoded.length) {
Expand All @@ -5415,7 +5408,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
Loading