Skip to content

Commit

Permalink
Exclude namespace prefix from tag name when comparing against field n…
Browse files Browse the repository at this point in the history
…ames

This updates the "not_in" check that decides whether to pass a
new start tag within a struct to a $value field, to only consider
the local part of a QName. It now uses the same logic as the QNameDeserializer
that is used for keys/fields already to ensure they stay in sync.

Using the namespaced name in serde (i.e. `#[serde(rename = "ns1:tag")]`)
fails with ``Custom("missing field `ns1:tag`")`` today, so this will
not break existing code.

Co-authored-by: Xiphoseer <me@xiphoseer.de>
  • Loading branch information
2 people authored and Mingun committed May 13, 2024
1 parent 8d86e90 commit 6177189
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ to get an offset of the error position. For `SyntaxError`s the range
- [#684]: Fix incorrect position reported for `Error::IllFormed(DoubleHyphenInComment)`.
- [#684]: Fix incorrect position reported for `Error::IllFormed(MissingDoctypeName)`.
- [#704]: Fix empty tags with attributes not being expanded when `expand_empty_elements` is set to true.
- [#683]: Use local tag name when check tag name against possible names for field.

### Misc Changes

Expand Down Expand Up @@ -72,6 +73,7 @@ to get an offset of the error position. For `SyntaxError`s the range
[#629]: https://github.com/tafia/quick-xml/issues/629
[#675]: https://github.com/tafia/quick-xml/pull/675
[#677]: https://github.com/tafia/quick-xml/pull/677
[#683]: https://github.com/tafia/quick-xml/issues/683
[#684]: https://github.com/tafia/quick-xml/pull/684
[#689]: https://github.com/tafia/quick-xml/pull/689
[#704]: https://github.com/tafia/quick-xml/pull/704
Expand Down
2 changes: 1 addition & 1 deletion src/de/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ fn not_in(
start: &BytesStart,
decoder: Decoder,
) -> Result<bool, DeError> {
let tag = decoder.decode(start.name().into_inner())?;
let tag = decoder.decode(start.local_name().into_inner())?;

Ok(fields.iter().all(|&field| field != tag.as_ref()))
}
Expand Down

0 comments on commit 6177189

Please sign in to comment.