Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tafia/quick-xml
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.37.2
Choose a base ref
...
head repository: tafia/quick-xml
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.37.3
Choose a head ref
  • 12 commits
  • 10 files changed
  • 2 contributors

Commits on Dec 29, 2024

  1. Remove accidently forgotten entry from changelog

    Mingun committed Dec 29, 2024
    Copy the full SHA
    8f91a9c View commit details

Commits on Mar 8, 2025

  1. Update code according to new rustfmt rules (run cargo fmt)

    Mingun committed Mar 8, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c8fe850 View commit details

Commits on Mar 16, 2025

  1. Copy the full SHA
    40538b7 View commit details

Commits on Mar 21, 2025

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    41b6dc1 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    341db46 View commit details
  3. Use namespace-aware reader in serde deserializer

    This affects performance of the serde deserializer by ~20%, unfortunately
    weiznich authored and Mingun committed Mar 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b8ce862 View commit details
  4. Add regression tests for #497

    Mingun committed Mar 21, 2025
    Copy the full SHA
    521707c View commit details
  5. Add tests for xsi:nil handling

    failures (11):
        as_field::empty::nested::true_
        as_field::with_attr::nested::true_
        as_field::with_element::nested::true_
        as_field::with_element::ns0::true_
        as_field::with_element::xsi::true_
        top_level_option::empty::ns0::true_
        top_level_option::empty::xsi::true_
        top_level_option::with_attr::ns0::true_
        top_level_option::with_attr::xsi::true_
        top_level_option::with_element::ns0::true_
        top_level_option::with_element::xsi::true_
    Mingun committed Mar 21, 2025
    Copy the full SHA
    10b37f7 View commit details
  6. Properly use xsi:nil to deserialize null values via serde

    This commit fixes an issue that causes `quick-xml` trying to deserialize
    empty tags via the serde interface even if these tags were explicitly
    marked as `xsi:nil="true"`
    
    For example the following XML failed to deserialize before this commit:
    
    ```xml
    <bar>
    	<foo xsi:nil="true"/>
    </bar>
    ```
    
    into the following rust type:
    
    ```rust
    #[derive(Deserialize)]
    struct Bar {
        foo: Option<Foo>,
    }
    
    #[derive(Deserialize)]
    struct Foo {
        baz: String,
    }
    ```
    
    Before this commit this failed to deserialize with an error message that
    complained that the `baz` field was missing. After this commit this uses
    the `xsi:nil` attribute to deserialize this into `foo: None` instead.
    The standard (https://www.w3.org/TR/xmlschema-1/#xsi_nil) seems to
    support this behaviour.
    
    Fix #497
    weiznich authored and Mingun committed Mar 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6176c33 View commit details
  7. Migrate to actions/upload-artifact@v4 in fuzzer sub-project

    Mingun committed Mar 21, 2025
    Copy the full SHA
    3c4de88 View commit details

Commits on Mar 25, 2025

  1. Merge pull request #850 from Mingun/fix/honor_xsi_nil

    Properly use xsi:nil to deserialize null values via serde
    Mingun authored Mar 25, 2025
    Copy the full SHA
    44644b3 View commit details
  2. Release 0.37.3

    Mingun committed Mar 25, 2025
    Copy the full SHA
    2cedfe1 View commit details
Showing with 1,043 additions and 37 deletions.
  1. +1 −1 .github/workflows/cifuzz.yml
  2. +6 −1 Cargo.toml
  3. +12 −2 Changelog.md
  4. +22 −1 src/de/map.rs
  5. +138 −20 src/de/mod.rs
  6. +128 −8 src/events/attributes.rs
  7. +1 −1 src/name.rs
  8. +14 −3 src/reader/async_tokio.rs
  9. +704 −0 tests/serde-de-xsi.rs
  10. +17 −0 tests/serde-issues.rs
2 changes: 1 addition & 1 deletion .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ jobs:
language: rust
fuzz-seconds: 600
- name: Upload Crash
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quick-xml"
version = "0.37.2"
version = "0.37.3"
description = "High performance xml reader and writer"
edition = "2021"

@@ -231,6 +231,11 @@ name = "serde-de-seq"
required-features = ["serialize"]
path = "tests/serde-de-seq.rs"

[[test]]
name = "serde-de-xsi"
required-features = ["serialize"]
path = "tests/serde-de-xsi.rs"

[[test]]
name = "serde-se"
required-features = ["serialize"]
14 changes: 12 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -15,13 +15,23 @@

### New Features

- [#836]: Add `se::to_utf8_io_writer()` helper compatible with `std::io::Write` and restricted to UTF-8 encoding.

### Bug Fixes

### Misc Changes


## 0.37.3 -- 2025-03-25

### New Features

- [#850]: Add `Attribute::as_bool()` method to get an attribute value as a boolean.
- [#850]: Add `Attributes::has_nil()` method to check if attributes has `xsi:nil` attribute set to `true`.
- [#497]: Handle `xsi:nil` attribute in serde Deserializer to better process optional fields.

[#497]: https://github.com/tafia/quick-xml/issues/497
[#850]: https://github.com/tafia/quick-xml/pull/850


## 0.37.2 -- 2024-12-29

### New Features
23 changes: 22 additions & 1 deletion src/de/map.rs
Original file line number Diff line number Diff line change
@@ -215,6 +215,21 @@ where
has_value_field: fields.contains(&VALUE_KEY),
})
}

/// Determines if subtree started with the specified event shoould be skipped.
///
/// Used to map elements with `xsi:nil` attribute set to true to `None` in optional contexts.
///
/// We need to handle two attributes:
/// - on parent element: <map xsi:nil="true"><foo/></map>
/// - on this element: <map><foo xsi:nil="true"/></map>
///
/// We check parent element too because `xsi:nil` affects only nested elements of the
/// tag where it is defined. We can map structure with fields mapped to attributes to
/// the `<map>` element and set to `None` all its optional elements.
fn should_skip_subtree(&self, start: &BytesStart) -> bool {
self.de.reader.reader.has_nil_attr(&self.start) || self.de.reader.reader.has_nil_attr(start)
}
}

impl<'de, 'd, R, E> MapAccess<'de> for ElementMapAccess<'de, 'd, R, E>
@@ -540,8 +555,14 @@ where
where
V: Visitor<'de>,
{
match self.map.de.peek()? {
// We cannot use result of `peek()` directly because of borrow checker
let _ = self.map.de.peek()?;
match self.map.de.last_peeked() {
DeEvent::Text(t) if t.is_empty() => visitor.visit_none(),
DeEvent::Start(start) if self.map.should_skip_subtree(start) => {
self.map.de.skip_next_tree()?;
visitor.visit_none()
}
_ => visitor.visit_some(self),
}
}
Loading