Skip to content

Commit a990db7

Browse files
authored
fix(clients): trim values in parsed xml only if result is empty (#2194)
1 parent 325d6b4 commit a990db7

File tree

27 files changed

+55
-28
lines changed

27 files changed

+55
-28
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -8908,7 +8908,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
89088908
attributeNamePrefix: "",
89098909
ignoreAttributes: false,
89108910
parseNodeValue: false,
8911-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
8911+
trimValues: false,
8912+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
89128913
});
89138914
const textNodeName = "#text";
89148915
const key = Object.keys(parsedObj)[0];

clients/client-cloudformation/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -9598,7 +9598,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
95989598
attributeNamePrefix: "",
95999599
ignoreAttributes: false,
96009600
parseNodeValue: false,
9601-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
9601+
trimValues: false,
9602+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
96029603
});
96039604
const textNodeName = "#text";
96049605
const key = Object.keys(parsedObj)[0];

clients/client-cloudfront/protocols/Aws_restXml.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -17052,7 +17052,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1705217052
attributeNamePrefix: "",
1705317053
ignoreAttributes: false,
1705417054
parseNodeValue: false,
17055-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
17055+
trimValues: false,
17056+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
1705617057
});
1705717058
const textNodeName = "#text";
1705817059
const key = Object.keys(parsedObj)[0];

clients/client-cloudsearch/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -4875,7 +4875,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
48754875
attributeNamePrefix: "",
48764876
ignoreAttributes: false,
48774877
parseNodeValue: false,
4878-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
4878+
trimValues: false,
4879+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
48794880
});
48804881
const textNodeName = "#text";
48814882
const key = Object.keys(parsedObj)[0];

clients/client-cloudwatch/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5473,7 +5473,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
54735473
attributeNamePrefix: "",
54745474
ignoreAttributes: false,
54755475
parseNodeValue: false,
5476-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
5476+
trimValues: false,
5477+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
54775478
});
54785479
const textNodeName = "#text";
54795480
const key = Object.keys(parsedObj)[0];

clients/client-docdb/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8712,7 +8712,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
87128712
attributeNamePrefix: "",
87138713
ignoreAttributes: false,
87148714
parseNodeValue: false,
8715-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
8715+
trimValues: false,
8716+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
87168717
});
87178718
const textNodeName = "#text";
87188719
const key = Object.keys(parsedObj)[0];

clients/client-ec2/protocols/Aws_ec2.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -70099,7 +70099,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
7009970099
attributeNamePrefix: "",
7010070100
ignoreAttributes: false,
7010170101
parseNodeValue: false,
70102-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
70102+
trimValues: false,
70103+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
7010370104
});
7010470105
const textNodeName = "#text";
7010570106
const key = Object.keys(parsedObj)[0];

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -8209,7 +8209,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
82098209
attributeNamePrefix: "",
82108210
ignoreAttributes: false,
82118211
parseNodeValue: false,
8212-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
8212+
trimValues: false,
8213+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
82138214
});
82148215
const textNodeName = "#text";
82158216
const key = Object.keys(parsedObj)[0];

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -7865,7 +7865,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
78657865
attributeNamePrefix: "",
78667866
ignoreAttributes: false,
78677867
parseNodeValue: false,
7868-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
7868+
trimValues: false,
7869+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
78697870
});
78707871
const textNodeName = "#text";
78717872
const key = Object.keys(parsedObj)[0];

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -5414,7 +5414,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
54145414
attributeNamePrefix: "",
54155415
ignoreAttributes: false,
54165416
parseNodeValue: false,
5417-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
5417+
trimValues: false,
5418+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
54185419
});
54195420
const textNodeName = "#text";
54205421
const key = Object.keys(parsedObj)[0];

clients/client-elasticache/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14384,7 +14384,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1438414384
attributeNamePrefix: "",
1438514385
ignoreAttributes: false,
1438614386
parseNodeValue: false,
14387-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
14387+
trimValues: false,
14388+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
1438814389
});
1438914390
const textNodeName = "#text";
1439014391
const key = Object.keys(parsedObj)[0];

clients/client-iam/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -19108,7 +19108,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1910819108
attributeNamePrefix: "",
1910919109
ignoreAttributes: false,
1911019110
parseNodeValue: false,
19111-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
19111+
trimValues: false,
19112+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
1911219113
});
1911319114
const textNodeName = "#text";
1911419115
const key = Object.keys(parsedObj)[0];

clients/client-neptune/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -13178,7 +13178,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1317813178
attributeNamePrefix: "",
1317913179
ignoreAttributes: false,
1318013180
parseNodeValue: false,
13181-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
13181+
trimValues: false,
13182+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
1318213183
});
1318313184
const textNodeName = "#text";
1318413185
const key = Object.keys(parsedObj)[0];

clients/client-rds/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -27087,7 +27087,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
2708727087
attributeNamePrefix: "",
2708827088
ignoreAttributes: false,
2708927089
parseNodeValue: false,
27090-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
27090+
trimValues: false,
27091+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
2709127092
});
2709227093
const textNodeName = "#text";
2709327094
const key = Object.keys(parsedObj)[0];

clients/client-redshift/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -18582,7 +18582,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1858218582
attributeNamePrefix: "",
1858318583
ignoreAttributes: false,
1858418584
parseNodeValue: false,
18585-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
18585+
trimValues: false,
18586+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
1858618587
});
1858718588
const textNodeName = "#text";
1858818589
const key = Object.keys(parsedObj)[0];

clients/client-route-53/protocols/Aws_restXml.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -9011,7 +9011,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
90119011
attributeNamePrefix: "",
90129012
ignoreAttributes: false,
90139013
parseNodeValue: false,
9014-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
9014+
trimValues: false,
9015+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
90159016
});
90169017
const textNodeName = "#text";
90179018
const key = Object.keys(parsedObj)[0];

clients/client-s3-control/protocols/Aws_restXml.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6771,7 +6771,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
67716771
attributeNamePrefix: "",
67726772
ignoreAttributes: false,
67736773
parseNodeValue: false,
6774-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
6774+
trimValues: false,
6775+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
67756776
});
67766777
const textNodeName = "#text";
67776778
const key = Object.keys(parsedObj)[0];

clients/client-s3/protocols/Aws_restXml.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14317,7 +14317,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1431714317
attributeNamePrefix: "",
1431814318
ignoreAttributes: false,
1431914319
parseNodeValue: false,
14320-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
14320+
trimValues: false,
14321+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
1432114322
});
1432214323
const textNodeName = "#text";
1432314324
const key = Object.keys(parsedObj)[0];

clients/client-ses/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -10324,7 +10324,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1032410324
attributeNamePrefix: "",
1032510325
ignoreAttributes: false,
1032610326
parseNodeValue: false,
10327-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
10327+
trimValues: false,
10328+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
1032810329
});
1032910330
const textNodeName = "#text";
1033010331
const key = Object.keys(parsedObj)[0];

clients/client-sns/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5334,7 +5334,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
53345334
attributeNamePrefix: "",
53355335
ignoreAttributes: false,
53365336
parseNodeValue: false,
5337-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
5337+
trimValues: false,
5338+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
53385339
});
53395340
const textNodeName = "#text";
53405341
const key = Object.keys(parsedObj)[0];

clients/client-sqs/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3145,7 +3145,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
31453145
attributeNamePrefix: "",
31463146
ignoreAttributes: false,
31473147
parseNodeValue: false,
3148-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
3148+
trimValues: false,
3149+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
31493150
});
31503151
const textNodeName = "#text";
31513152
const key = Object.keys(parsedObj)[0];

clients/client-sts/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
14701470
attributeNamePrefix: "",
14711471
ignoreAttributes: false,
14721472
parseNodeValue: false,
1473-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
1473+
trimValues: false,
1474+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
14741475
});
14751476
const textNodeName = "#text";
14761477
const key = Object.keys(parsedObj)[0];

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ static void generateXmlParseBody(GenerationContext context) {
130130
+ "any => collectBodyString(streamBody, context).then(encoded => {", "});", () -> {
131131
writer.openBlock("if (encoded.length) {", "}", () -> {
132132
writer.write("const parsedObj = xmlParse(encoded, { attributeNamePrefix: '', "
133-
+ "ignoreAttributes: false, parseNodeValue: false, tagValueProcessor: (val, tagName) "
134-
+ "=> decodeEscapedXML(val) });");
133+
+ "ignoreAttributes: false, parseNodeValue: false, trimValues: false, "
134+
+ "tagValueProcessor: (val, tagName) => val.trim() === '' ? "
135+
+ "'': decodeEscapedXML(val) });");
135136
writer.write("const textNodeName = '#text';");
136137
writer.write("const key = Object.keys(parsedObj)[0];");
137138
writer.write("const parsedObjToReturn = parsedObj[key];");

protocol_tests/aws-ec2/protocols/Aws_ec2.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2152,7 +2152,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
21522152
attributeNamePrefix: "",
21532153
ignoreAttributes: false,
21542154
parseNodeValue: false,
2155-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
2155+
trimValues: false,
2156+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
21562157
});
21572158
const textNodeName = "#text";
21582159
const key = Object.keys(parsedObj)[0];

protocol_tests/aws-query/protocols/Aws_query.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2928,7 +2928,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
29282928
attributeNamePrefix: "",
29292929
ignoreAttributes: false,
29302930
parseNodeValue: false,
2931-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
2931+
trimValues: false,
2932+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
29322933
});
29332934
const textNodeName = "#text";
29342935
const key = Object.keys(parsedObj)[0];

protocol_tests/aws-restxml/protocols/Aws_restXml.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5569,7 +5569,8 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
55695569
attributeNamePrefix: "",
55705570
ignoreAttributes: false,
55715571
parseNodeValue: false,
5572-
tagValueProcessor: (val, tagName) => decodeEscapedXML(val),
5572+
trimValues: false,
5573+
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeEscapedXML(val)),
55735574
});
55745575
const textNodeName = "#text";
55755576
const key = Object.keys(parsedObj)[0];

protocol_tests/aws-restxml/tests/functional/restxml.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5301,7 +5301,8 @@ const compareEquivalentXmlBodies = (expectedBody: string, generatedBody: string)
53015301
attributeNamePrefix: "",
53025302
ignoreAttributes: false,
53035303
parseNodeValue: false,
5304-
tagValueProcessor: (val: any, tagName: any) => decodeEscapedXml(val),
5304+
trimValues: false,
5305+
tagValueProcessor: (val: any, tagName: any) => (val.trim() === "" ? "" : decodeEscapedXml(val)),
53055306
};
53065307

53075308
const parseXmlBody = (body: string) => {

0 commit comments

Comments
 (0)