mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-07 21:33:13 +00:00
ignore checksums with empty/whitespace-only bodies
aws-sdk-cpp was observed to send request bodies like this via Lix: ```xml <?xml version="1.0"?> <CompleteMultipartUpload xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Part> <ETag>"8a5031bda169553d6a232e6c11068774"</ETag> <ChecksumCRC32></ChecksumCRC32> <PartNumber>1</PartNumber> </Part> <Part> <ETag>"da977cc58b75bd17749c1ff460ba301a"</ETag> <ChecksumCRC32></ChecksumCRC32> <PartNumber>2</PartNumber> </Part> </CompleteMultipartUpload> ```
This commit is contained in:
+15
-3
@@ -611,9 +611,21 @@ macro_rules! extract_checksum_from {
|
||||
if false { None }
|
||||
$(
|
||||
else if let Some(node) = $node.children().find(|e| e.has_tag_name($name)) {
|
||||
Some(ChecksumValue::$variant(
|
||||
BASE64_STANDARD.decode(node.text()?).ok()?[..].try_into().ok()?
|
||||
))
|
||||
match node.last_child().map(|x| x.text()) {
|
||||
// Child is text but empty post-trim, ignore it.
|
||||
Some(Some(text)) if text.trim().is_empty() => None,
|
||||
|
||||
// Child is non-empty text, parse it.
|
||||
Some(Some(text)) => Some(ChecksumValue::$variant(
|
||||
BASE64_STANDARD.decode(text).ok()?[..].try_into().ok()?
|
||||
)),
|
||||
|
||||
// Child is not text, reject it.
|
||||
Some(None) => return None,
|
||||
|
||||
// No child, ignore it.
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
)*
|
||||
else { None }
|
||||
|
||||
Reference in New Issue
Block a user