Copilot commented on code in PR #921:
URL:
https://github.com/apache/arrow-rs-object-store/pull/921#discussion_r4713339833
##########
src/aws/client.rs:
##########
@@ -491,6 +499,84 @@ impl Request<'_> {
}
}
+pub(crate) async fn validate_copy_response(response: HttpResponse) ->
Result<()> {
+ let data = response
+ .into_body()
+ .bytes()
+ .await
+ .map_err(|source| Error::CopyResponseBody { source })?;
+
+ let body = std::str::from_utf8(&data).map_err(|source|
Error::InvalidCopyResponse {
+ source: Box::new(source),
+ })?;
+
+ let mut reader = quick_xml::Reader::from_str(body);
+ let mut depth: usize = 0;
+ let mut saw_root = false;
+
+ loop {
+ match reader.read_event() {
Review Comment:
`read_event()` emits [unchecked
attributes](https://github.com/tafia/quick-xml/blob/e3c3e3a28b23d40093abc881c0da39cb94869a87/src/events/mod.rs#L134-L140),
and this loop also ignores entity references inside the root, so malformed
responses such as `<CopyObjectResult broken/>`, duplicate attributes, or
`<CopyObjectResult><ETag>&undefined;</ETag></CopyObjectResult>` return
`Ok(())`. Validate attributes and their escaped values on both `Start` and
`Empty` events, and reject invalid or unresolved entity references. Add
regression cases for these malformed responses while keeping ETag optional.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]