Unverified Commit d9eafb5b authored by Nugine's avatar Nugine
Browse files

s3s: xml: translate empty element

parent 4da32030
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -409,7 +409,11 @@ impl SignatureContext<'_> {
            } else {
                let bytes = extract_full_body(self.req, self.body).await?;

                if bytes.len() < 1024 {
                    debug!(len=?bytes.len(), body=?bytes, "extracted full body");
                } else {
                    debug!(len=?bytes.len(), "extracted full body");
                }

                let payload = if matches!(amz_content_sha256, AmzContentSha256::UnsignedPayload) {
                    signature_v4::Payload::Unsigned
+9 −0
Original line number Diff line number Diff line
@@ -60,3 +60,12 @@ fn d003() {
    assert_eq!(tag.key, "Key4");
    assert_eq!(tag.value, "Value4");
}

#[test]
fn d004() {
    let input = read(concat!(DATA_DIR, "/d004.xml"));
    let ans = deserialize::<crate::dto::SelectObjectContentRequest>(&input).unwrap();

    assert!(ans.input_serialization.csv.is_some());
    assert!(ans.output_serialization.csv.is_some());
}
+13 −0
Original line number Diff line number Diff line
<SelectObjectContentRequest xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <Expression>select * from s3object</Expression>
    <ExpressionType>SQL</ExpressionType>
    <InputSerialization>
        <CSV />
    </InputSerialization>
    <OutputSerialization>
        <CSV />
    </OutputSerialization>
    <RequestProgress>
        <Enabled>true</Enabled>
    </RequestProgress>
</SelectObjectContentRequest>
 No newline at end of file
+14 −3
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@ pub struct Deserializer<'xml> {

    /// peeked event
    peeked: Option<DeEvent<'xml>>,

    /// store an extra event
    next_slot: Option<DeEvent<'xml>>,
}

/// XML deserialization result
@@ -96,11 +99,15 @@ impl<'xml> Deserializer<'xml> {
        Self {
            inner: Reader::from_reader(xml),
            peeked: None,
            next_slot: None,
        }
    }

    /// Reads the next event
    fn read_event(&mut self) -> DeResult<DeEvent<'xml>> {
        if let Some(ev) = self.next_slot.take() {
            return Ok(ev);
        }
        loop {
            let ev = self.inner.read_event().map_err(invalid_xml)?;
            let de = match ev {
@@ -109,10 +116,14 @@ impl<'xml> Deserializer<'xml> {
                Event::Text(x) => DeEvent::Text(x),
                Event::Eof => DeEvent::Eof,

                // ignore the others
                Event::Empty(_) | Event::Comment(_) | Event::CData(_) | Event::Decl(_) | Event::PI(_) | Event::DocType(_) => {
                    continue
                Event::Empty(x) => {
                    // translate `<CSV/>` to `<CSV></CSV>`
                    self.next_slot = Some(DeEvent::End(x.to_end().into_owned()));
                    DeEvent::Start(x)
                }

                // ignore the others
                Event::Comment(_) | Event::CData(_) | Event::Decl(_) | Event::PI(_) | Event::DocType(_) => continue,
            };
            break Ok(de);
        }
+2 −2
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ if __name__ == "__main__":
    assert counts["aws-sdk-ruby"]["fail"] == 0
    assert counts["mc"]["fail"] == 0
    assert counts["s3cmd"]["fail"] == 0
    assert counts["s3select"]["fail"] == 0

    # FIXME: E2E tests
    assert counts["aws-sdk-php"]["pass"] >= 12
@@ -72,8 +73,7 @@ if __name__ == "__main__":
    assert counts["minio-dotnet"]["pass"] >= 1
    assert counts["minio-go"]["pass"] >= 1
    assert counts["minio-java"]["pass"] >= 8
    assert counts["minio-py"]["pass"] >= 12
    assert counts["minio-py"]["pass"] >= 13
    assert counts["versioning"]["pass"] >= 4

    # assert counts["minio-js"]["pass"] >= 0
    # assert counts["s3select"]["pass"] >= 0