From 7550d230df6faac5c1cdbbfeab57b671a7479b6e Mon Sep 17 00:00:00 2001 From: Jill Date: Fri, 14 Jan 2022 14:17:23 +0100 Subject: [PATCH 1/2] garage_api(multipart_upload): Fix incorrect error on some weird Multipart Upload body --- src/api/s3_put.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/api/s3_put.rs b/src/api/s3_put.rs index 4e85664b..49b04f29 100644 --- a/src/api/s3_put.rs +++ b/src/api/s3_put.rs @@ -715,6 +715,11 @@ fn parse_complete_multpart_upload_body( } for item in cmu.children() { + // Only parse nodes + if !item.is_element() { + continue; + } + if item.has_tag_name("Part") { let etag = item.children().find(|e| e.has_tag_name("ETag"))?.text()?; let part_number = item -- 2.45.2 From 9a22c9905bd4f820e44e7f9cd3d349e67ddda25b Mon Sep 17 00:00:00 2001 From: Jill Date: Fri, 14 Jan 2022 14:18:08 +0100 Subject: [PATCH 2/2] garage_api(fixup): Fix typo on Multipart Upload parsing function --- src/api/s3_put.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/s3_put.rs b/src/api/s3_put.rs index 49b04f29..a3ae290d 100644 --- a/src/api/s3_put.rs +++ b/src/api/s3_put.rs @@ -511,7 +511,7 @@ pub async fn handle_complete_multipart_upload( } let body_xml = roxmltree::Document::parse(std::str::from_utf8(&body)?)?; - let body_list_of_parts = parse_complete_multpart_upload_body(&body_xml) + let body_list_of_parts = parse_complete_multipart_upload_body(&body_xml) .ok_or_bad_request("Invalid CompleteMultipartUpload XML")?; debug!( "CompleteMultipartUpload list of parts: {:?}", @@ -703,7 +703,7 @@ struct CompleteMultipartUploadPart { part_number: u64, } -fn parse_complete_multpart_upload_body( +fn parse_complete_multipart_upload_body( xml: &roxmltree::Document, ) -> Option> { let mut parts = vec![]; -- 2.45.2