Skip to content

Commit ccf2d3f

Browse files
pauldrapertrivikr
authored andcommitted
fix(clients): properly decode SQS messages
Fixes #2362.
1 parent ed302dc commit ccf2d3f

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

clients/client-sqs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@aws-sdk/util-utf8-browser": "3.13.1",
5959
"@aws-sdk/util-utf8-node": "3.13.1",
6060
"fast-xml-parser": "3.19.0",
61+
"he": "^1.0.0",
6162
"tslib": "^2.0.0"
6263
},
6364
"devDependencies": {

clients/client-sqs/protocols/Aws_query.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ import {
102102
SerdeContext as __SerdeContext,
103103
} from "@aws-sdk/types";
104104
import { parse as xmlParse } from "fast-xml-parser";
105+
import { decode as xmlDecode } from "he";
105106

106107
export const serializeAws_queryAddPermissionCommand = async (
107108
input: AddPermissionCommandInput,
@@ -3130,14 +3131,6 @@ const buildHttpRpcRequest = async (
31303131
return new __HttpRequest(contents);
31313132
};
31323133

3133-
const decodeEscapedXML = (str: string) =>
3134-
str
3135-
.replace(/&/g, "&")
3136-
.replace(/'/g, "'")
3137-
.replace(/"/g, '"')
3138-
.replace(/>/g, ">")
3139-
.replace(/&lt;/g, "<");
3140-
31413134
const parseBody = (streamBody: any, context: __SerdeContext): any =>
31423135
collectBodyString(streamBody, context).then((encoded) => {
31433136
if (encoded.length) {
@@ -3146,7 +3139,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
31463139
ignoreAttributes: false,
31473140
parseNodeValue: false,
31483141
trimValues: false,
3149-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
3142+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : xmlDecode(val)),
31503143
});
31513144
const textNodeName = "#text";
31523145
const key = Object.keys(parsedObj)[0];

yarn.lock

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,11 @@
16971697
dependencies:
16981698
"@types/node" "*"
16991699

1700+
"@types/he@^1.0.0":
1701+
version "1.1.1"
1702+
resolved "https://registry.yarnpkg.com/@types/he/-/he-1.1.1.tgz#19e14033c4ee8f1a702c74dcc6182664839ac2b7"
1703+
integrity sha512-jpzrsR1ns0n3kyWt92QfOUQhIuJGQ9+QGa7M62rO6toe98woQjnsnzjdMtsQXCdvjjmqjS2ZBCC7xKw0cdzU+Q==
1704+
17001705
"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1":
17011706
version "2.0.3"
17021707
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz#4ba8ddb720221f432e443bd5f9117fd22cfd4762"
@@ -5803,7 +5808,7 @@ hash.js@^1.0.0, hash.js@^1.0.3:
58035808
inherits "^2.0.3"
58045809
minimalistic-assert "^1.0.1"
58055810

5806-
5811+
[email protected], he@^1.0.0:
58075812
version "1.2.0"
58085813
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
58095814
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==

0 commit comments

Comments
 (0)