Skip to content

Comments

Consider XML version when parse XML using Deserializer#938

Merged
Mingun merged 4 commits intotafia:masterfrom
Mingun:xml-version
Feb 20, 2026
Merged

Consider XML version when parse XML using Deserializer#938
Mingun merged 4 commits intotafia:masterfrom
Mingun:xml-version

Conversation

@Mingun
Copy link
Collaborator

@Mingun Mingun commented Feb 15, 2026

XML 1.0 and XML 1.1 has different rules for end-of-line normalization. Previously quick-xml used XML 1.1 rules, while it should rely on XML declaration.

After this PR XML declaration will be dictate the mode.

This PR introduces XmlVersion enumeration and makes breaking changes for xml_version() methods: now they accept the version.

Because in practice there very highly unlikely will be versions other that 1.0 and 1.1, all other version strings produces new IllFormedError::UnknownVersion error.

@Mingun Mingun added bug serde Issues related to mapping from Rust types to XML labels Feb 15, 2026
@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 78.94737% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.08%. Comparing base (2b21d40) to head (a759d65).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
src/events/mod.rs 73.68% 5 Missing ⚠️
benches/macrobenches.rs 0.00% 4 Missing ⚠️
src/lib.rs 78.94% 4 Missing ⚠️
benches/microbenches.rs 0.00% 1 Missing ⚠️
src/de/mod.rs 96.87% 1 Missing ⚠️
src/errors.rs 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #938      +/-   ##
==========================================
+ Coverage   55.00%   55.08%   +0.08%     
==========================================
  Files          44       44              
  Lines       16816    16911      +95     
==========================================
+ Hits         9249     9316      +67     
- Misses       7567     7595      +28     
Flag Coverage Δ
unittests 55.08% <78.94%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}
Event::Text(e) => {
black_box(e.xml_content()?);
black_box(e.xml10_content()?);
Copy link
Collaborator

@dralley dralley Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why bother with this when xml_content() is what you would generally expect users to be using more frequently?

This makes it explicit, but I don't see why making it explicit matters in this case, given (as the commit message states) all documents declare being version 1.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally I expect that people will read Event::Decl, store .xml_version() from it and use that version in .xml_content(). For that xml_content() was changed in the next commit to accept XmlVersion.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my mind that still means we would want to benchmark .xml_content(XmlVersion::1_0), because that is how we expect it to be used. Especially for "macro" benchmarks.

I understand the practical difference is basically nonexistent, it's more philosophical. And just a suggestion. Not going to block over it.

Copy link
Collaborator

@dralley dralley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from my question, this looks good

In all places XML documents has version 1.0, so explicitly request content in that version
failures:
    xml_version::unknown
    xml_version::v1_0_explicit
    xml_version::v1_0_implicit
@Mingun Mingun merged commit 5ac1e9e into tafia:master Feb 20, 2026
7 checks passed
@Mingun Mingun deleted the xml-version branch February 20, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug serde Issues related to mapping from Rust types to XML

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants