Skip to content

Commit

Permalink
fix(clients): only trim xml tag values which contain newline (#2653)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Aug 13, 2021
1 parent 16241cf commit 28336f5
Show file tree
Hide file tree
Showing 27 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion clients/client-auto-scaling/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10008,7 +10008,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-cloudformation/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11149,7 +11149,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-cloudfront/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19025,7 +19025,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-cloudsearch/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4921,7 +4921,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-cloudwatch/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6370,7 +6370,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-docdb/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10727,7 +10727,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-ec2/protocols/Aws_ec2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74754,7 +74754,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-elastic-beanstalk/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8205,7 +8205,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7863,7 +7863,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5410,7 +5410,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-elasticache/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15016,7 +15016,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-iam/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21436,7 +21436,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-neptune/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13195,7 +13195,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-rds/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28153,7 +28153,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-redshift/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22294,7 +22294,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-route-53/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10422,7 +10422,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-s3-control/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8182,7 +8182,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-s3/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14724,7 +14724,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-ses/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10320,7 +10320,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-sns/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6347,7 +6347,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-sqs/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3141,7 +3141,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion clients/client-sts/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ static void generateXmlParseBody(GenerationContext context) {
writer.openBlock("if (encoded.length) {", "}", () -> {
writer.write("const parsedObj = xmlParse(encoded, { attributeNamePrefix: '', "
+ "ignoreAttributes: false, parseNodeValue: false, trimValues: false, "
+ "tagValueProcessor: (val, tagName) => val.trim() === '' ? '': decodeHTML(val) });");
+ "tagValueProcessor: (val) => (val.trim() === '' && val.includes('\\n'))"
+ " ? '': decodeHTML(val) });");
writer.write("const textNodeName = '#text';");
writer.write("const key = Object.keys(parsedObj)[0];");
writer.write("const parsedObjToReturn = parsedObj[key];");
Expand Down Expand Up @@ -293,10 +294,6 @@ private static boolean filterProtocolTests(
if (testCase.getId().equals("QueryCustomizedError")) {
return true;
}
// TODO: follow-up with smithy on whether whitespace strings should be trimmed.
if (testCase.getId().equals("SimpleScalarPropertiesPureWhiteSpace")) {
return true;
}
return false;
}
}
2 changes: 1 addition & 1 deletion protocol_tests/aws-ec2/protocols/Aws_ec2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion protocol_tests/aws-query/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3002,7 +3002,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
2 changes: 1 addition & 1 deletion protocol_tests/aws-restxml/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6173,7 +6173,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any =>
ignoreAttributes: false,
parseNodeValue: false,
trimValues: false,
tagValueProcessor: (val, tagName) => (val.trim() === "" ? "" : decodeHTML(val)),
tagValueProcessor: (val) => (val.trim() === "" && val.includes("\n") ? "" : decodeHTML(val)),
});
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
Expand Down
4 changes: 2 additions & 2 deletions protocol_tests/aws-restxml/tests/functional/restxml.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3780,7 +3780,7 @@ it("SimpleScalarPropertiesWithWhiteSpace:Request", async () => {
/**
* Serializes string containing exclusively whitespace
*/
it.skip("SimpleScalarPropertiesPureWhiteSpace:Request", async () => {
it("SimpleScalarPropertiesPureWhiteSpace:Request", async () => {
const client = new RestXmlProtocolClient({
...clientParams,
requestHandler: new RequestSerializationTestHandler(),
Expand Down Expand Up @@ -4203,7 +4203,7 @@ it("SimpleScalarPropertiesWithWhiteSpace:Response", async () => {
/**
* Serializes string containing white space
*/
it.skip("SimpleScalarPropertiesPureWhiteSpace:Response", async () => {
it("SimpleScalarPropertiesPureWhiteSpace:Response", async () => {
const client = new RestXmlProtocolClient({
...clientParams,
requestHandler: new ResponseDeserializationTestHandler(
Expand Down

0 comments on commit 28336f5

Please sign in to comment.