Skip to content

Commit 28336f5

Browse files
authored
fix(clients): only trim xml tag values which contain newline (#2653)
1 parent 16241cf commit 28336f5

File tree

27 files changed

+29
-32
lines changed

27 files changed

+29
-32
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -10008,7 +10008,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1000810008
ignoreAttributes: false,
1000910009
parseNodeValue: false,
1001010010
trimValues: false,
10011-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
10011+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
1001210012
});
1001310013
const textNodeName = "#text";
1001410014
const key = Object.keys(parsedObj)[0];

clients/client-cloudformation/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11149,7 +11149,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1114911149
ignoreAttributes: false,
1115011150
parseNodeValue: false,
1115111151
trimValues: false,
11152-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
11152+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
1115311153
});
1115411154
const textNodeName = "#text";
1115511155
const key = Object.keys(parsedObj)[0];

clients/client-cloudfront/protocols/Aws_restXml.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19025,7 +19025,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1902519025
ignoreAttributes: false,
1902619026
parseNodeValue: false,
1902719027
trimValues: false,
19028-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
19028+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
1902919029
});
1903019030
const textNodeName = "#text";
1903119031
const key = Object.keys(parsedObj)[0];

clients/client-cloudsearch/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4921,7 +4921,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
49214921
ignoreAttributes: false,
49224922
parseNodeValue: false,
49234923
trimValues: false,
4924-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
4924+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
49254925
});
49264926
const textNodeName = "#text";
49274927
const key = Object.keys(parsedObj)[0];

clients/client-cloudwatch/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6370,7 +6370,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
63706370
ignoreAttributes: false,
63716371
parseNodeValue: false,
63726372
trimValues: false,
6373-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
6373+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
63746374
});
63756375
const textNodeName = "#text";
63766376
const key = Object.keys(parsedObj)[0];

clients/client-docdb/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10727,7 +10727,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1072710727
ignoreAttributes: false,
1072810728
parseNodeValue: false,
1072910729
trimValues: false,
10730-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
10730+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
1073110731
});
1073210732
const textNodeName = "#text";
1073310733
const key = Object.keys(parsedObj)[0];

clients/client-ec2/protocols/Aws_ec2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74754,7 +74754,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
7475474754
ignoreAttributes: false,
7475574755
parseNodeValue: false,
7475674756
trimValues: false,
74757-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
74757+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
7475874758
});
7475974759
const textNodeName = "#text";
7476074760
const key = Object.keys(parsedObj)[0];

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -8205,7 +8205,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
82058205
ignoreAttributes: false,
82068206
parseNodeValue: false,
82078207
trimValues: false,
8208-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
8208+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
82098209
});
82108210
const textNodeName = "#text";
82118211
const key = Object.keys(parsedObj)[0];

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -7863,7 +7863,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
78637863
ignoreAttributes: false,
78647864
parseNodeValue: false,
78657865
trimValues: false,
7866-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
7866+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
78677867
});
78687868
const textNodeName = "#text";
78697869
const key = Object.keys(parsedObj)[0];

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5410,7 +5410,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
54105410
ignoreAttributes: false,
54115411
parseNodeValue: false,
54125412
trimValues: false,
5413-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
5413+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
54145414
});
54155415
const textNodeName = "#text";
54165416
const key = Object.keys(parsedObj)[0];

clients/client-elasticache/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15016,7 +15016,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1501615016
ignoreAttributes: false,
1501715017
parseNodeValue: false,
1501815018
trimValues: false,
15019-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
15019+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
1502015020
});
1502115021
const textNodeName = "#text";
1502215022
const key = Object.keys(parsedObj)[0];

clients/client-iam/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21436,7 +21436,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
2143621436
ignoreAttributes: false,
2143721437
parseNodeValue: false,
2143821438
trimValues: false,
21439-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
21439+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
2144021440
});
2144121441
const textNodeName = "#text";
2144221442
const key = Object.keys(parsedObj)[0];

clients/client-neptune/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13195,7 +13195,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1319513195
ignoreAttributes: false,
1319613196
parseNodeValue: false,
1319713197
trimValues: false,
13198-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
13198+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
1319913199
});
1320013200
const textNodeName = "#text";
1320113201
const key = Object.keys(parsedObj)[0];

clients/client-rds/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28153,7 +28153,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
2815328153
ignoreAttributes: false,
2815428154
parseNodeValue: false,
2815528155
trimValues: false,
28156-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
28156+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
2815728157
});
2815828158
const textNodeName = "#text";
2815928159
const key = Object.keys(parsedObj)[0];

clients/client-redshift/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22294,7 +22294,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
2229422294
ignoreAttributes: false,
2229522295
parseNodeValue: false,
2229622296
trimValues: false,
22297-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
22297+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
2229822298
});
2229922299
const textNodeName = "#text";
2230022300
const key = Object.keys(parsedObj)[0];

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -10422,7 +10422,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1042210422
ignoreAttributes: false,
1042310423
parseNodeValue: false,
1042410424
trimValues: false,
10425-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
10425+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
1042610426
});
1042710427
const textNodeName = "#text";
1042810428
const key = Object.keys(parsedObj)[0];

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -8182,7 +8182,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
81828182
ignoreAttributes: false,
81838183
parseNodeValue: false,
81848184
trimValues: false,
8185-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
8185+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
81868186
});
81878187
const textNodeName = "#text";
81888188
const key = Object.keys(parsedObj)[0];

clients/client-s3/protocols/Aws_restXml.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14724,7 +14724,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1472414724
ignoreAttributes: false,
1472514725
parseNodeValue: false,
1472614726
trimValues: false,
14727-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
14727+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
1472814728
});
1472914729
const textNodeName = "#text";
1473014730
const key = Object.keys(parsedObj)[0];

clients/client-ses/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10320,7 +10320,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
1032010320
ignoreAttributes: false,
1032110321
parseNodeValue: false,
1032210322
trimValues: false,
10323-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
10323+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
1032410324
});
1032510325
const textNodeName = "#text";
1032610326
const key = Object.keys(parsedObj)[0];

clients/client-sns/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6347,7 +6347,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
63476347
ignoreAttributes: false,
63486348
parseNodeValue: false,
63496349
trimValues: false,
6350-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
6350+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
63516351
});
63526352
const textNodeName = "#text";
63536353
const key = Object.keys(parsedObj)[0];

clients/client-sqs/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3141,7 +3141,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
31413141
ignoreAttributes: false,
31423142
parseNodeValue: false,
31433143
trimValues: false,
3144-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
3144+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
31453145
});
31463146
const textNodeName = "#text";
31473147
const key = Object.keys(parsedObj)[0];

clients/client-sts/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
14801480
ignoreAttributes: false,
14811481
parseNodeValue: false,
14821482
trimValues: false,
1483-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
1483+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
14841484
});
14851485
const textNodeName = "#text";
14861486
const key = Object.keys(parsedObj)[0];

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ static void generateXmlParseBody(GenerationContext context) {
135135
writer.openBlock("if (encoded.length) {", "}", () -> {
136136
writer.write("const parsedObj = xmlParse(encoded, { attributeNamePrefix: '', "
137137
+ "ignoreAttributes: false, parseNodeValue: false, trimValues: false, "
138-
+ "tagValueProcessor: (val, tagName) => val.trim() === '' ? '': decodeHTML(val) });");
138+
+ "tagValueProcessor: (val) => (val.trim() === '' && val.includes('\\n'))"
139+
+ " ? '': decodeHTML(val) });");
139140
writer.write("const textNodeName = '#text';");
140141
writer.write("const key = Object.keys(parsedObj)[0];");
141142
writer.write("const parsedObjToReturn = parsedObj[key];");
@@ -293,10 +294,6 @@ private static boolean filterProtocolTests(
293294
if (testCase.getId().equals("QueryCustomizedError")) {
294295
return true;
295296
}
296-
// TODO: follow-up with smithy on whether whitespace strings should be trimmed.
297-
if (testCase.getId().equals("SimpleScalarPropertiesPureWhiteSpace")) {
298-
return true;
299-
}
300297
return false;
301298
}
302299
}

protocol_tests/aws-ec2/protocols/Aws_ec2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2172,7 +2172,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
21722172
ignoreAttributes: false,
21732173
parseNodeValue: false,
21742174
trimValues: false,
2175-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
2175+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
21762176
});
21772177
const textNodeName = "#text";
21782178
const key = Object.keys(parsedObj)[0];

protocol_tests/aws-query/protocols/Aws_query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3002,7 +3002,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
30023002
ignoreAttributes: false,
30033003
parseNodeValue: false,
30043004
trimValues: false,
3005-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
3005+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
30063006
});
30073007
const textNodeName = "#text";
30083008
const key = Object.keys(parsedObj)[0];

protocol_tests/aws-restxml/protocols/Aws_restXml.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6173,7 +6173,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
61736173
ignoreAttributes: false,
61746174
parseNodeValue: false,
61756175
trimValues: false,
6176-
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
6176+
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
61776177
});
61786178
const textNodeName = "#text";
61796179
const key = Object.keys(parsedObj)[0];

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -3780,7 +3780,7 @@ it("SimpleScalarPropertiesWithWhiteSpace:Request", async () => {
37803780
/**
37813781
* Serializes string containing exclusively whitespace
37823782
*/
3783-
it.skip("SimpleScalarPropertiesPureWhiteSpace:Request", async () => {
3783+
it("SimpleScalarPropertiesPureWhiteSpace:Request", async () => {
37843784
const client = new RestXmlProtocolClient({
37853785
...clientParams,
37863786
requestHandler: new RequestSerializationTestHandler(),
@@ -4203,7 +4203,7 @@ it("SimpleScalarPropertiesWithWhiteSpace:Response", async () => {
42034203
/**
42044204
* Serializes string containing white space
42054205
*/
4206-
it.skip("SimpleScalarPropertiesPureWhiteSpace:Response", async () => {
4206+
it("SimpleScalarPropertiesPureWhiteSpace:Response", async () => {
42074207
const client = new RestXmlProtocolClient({
42084208
...clientParams,
42094209
requestHandler: new ResponseDeserializationTestHandler(

0 commit comments

Comments
 (0)