From 74388f14fe415e83726428334f526d556501e7ea Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sun, 14 Sep 2025 12:23:41 +0200 Subject: [PATCH 1/3] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cd874e..102d3a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Enables the parsing of elements defined in another namespace in Person constructs [`#91`](https://github.com/rust-syndication/atom/pull/91) + ## 0.12.7 - 2025-02-16 - Publish tests [`#90`](https://github.com/rust-syndication/atom/pull/90) From e190170d816e3b563a08be42c7ba03d4ea101dc3 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sun, 14 Sep 2025 13:01:02 +0200 Subject: [PATCH 2/3] Update quick-xml to 0.38 --- CHANGELOG.md | 1 + Cargo.toml | 2 +- src/extension/util.rs | 22 ++++++++++++++++++---- src/util.rs | 28 +++++++++++++++++++++++----- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 102d3a2..a813d33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - Enables the parsing of elements defined in another namespace in Person constructs [`#91`](https://github.com/rust-syndication/atom/pull/91) +- Update `quick-xml` to `0.38` [`#92`](https://github.com/rust-syndication/atom/pull/92) ## 0.12.7 - 2025-02-16 diff --git a/Cargo.toml b/Cargo.toml index 6a0eea7..1ad161f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ categories = ["parser-implementations"] [dependencies] diligent-date-parser = "0.1.3" -quick-xml = { version = "0.37", features = ["encoding"] } +quick-xml = { version = "0.38", features = ["encoding"] } chrono = { version = "0.4", default-features = false, features = ["alloc"] } derive_builder = { version = "0.20", optional = true } never = { version = "0.1", optional = true } diff --git a/src/extension/util.rs b/src/extension/util.rs index 86ffdcd..9215d86 100644 --- a/src/extension/util.rs +++ b/src/extension/util.rs @@ -1,9 +1,11 @@ use std::collections::BTreeMap; use std::io::BufRead; -use quick_xml::events::attributes::Attributes; -use quick_xml::events::Event; -use quick_xml::Reader; +use quick_xml::{ + escape::resolve_predefined_entity, + events::{attributes::Attributes, Event}, + Reader, +}; use crate::error::{Error, XmlError}; use crate::extension::{Extension, ExtensionMap}; @@ -87,7 +89,19 @@ fn parse_extension_element( text.push_str(decode(&element, reader)?.as_ref()); } Event::Text(element) => { - text.push_str(element.unescape().map_err(XmlError::new)?.as_ref()); + text.push_str(element.decode().map_err(XmlError::new)?.as_ref()); + } + Event::GeneralRef(gref) => { + let entity = gref.decode().map_err(XmlError::new)?; + if let Some(resolved_entity) = resolve_predefined_entity(&entity) { + text.push_str(resolved_entity); + } else if let Some(ch) = gref.resolve_char_ref().map_err(XmlError::new)? { + text.push(ch); + } else { + text.push('&'); + text.push_str(&entity); + text.push(';'); + } } Event::End(element) => { extension.name = decode(element.name().as_ref(), reader)?.into(); diff --git a/src/util.rs b/src/util.rs index 2299f37..15ece0f 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,5 +1,5 @@ use quick_xml::{ - escape::escape, + escape::{escape, resolve_predefined_entity}, events::{attributes::Attribute, Event}, name::QName, Reader, @@ -86,11 +86,23 @@ pub fn atom_text(reader: &mut Reader) -> Result, E result.push_str(decode(&text, reader)?.as_ref()); } Event::Text(text) => { - let decoded = text.unescape().map_err(XmlError::new)?; + let decoded = text.decode().map_err(XmlError::new)?; result.push_str(&decoded); } + Event::GeneralRef(gref) => { + let entity = gref.decode().map_err(XmlError::new)?; + if let Some(resolved_entity) = resolve_predefined_entity(&entity) { + result.push_str(resolved_entity); + } else if let Some(ch) = gref.resolve_char_ref().map_err(XmlError::new)? { + result.push(ch); + } else { + result.push('&'); + result.push_str(&entity); + result.push(';'); + } + } Event::Comment(text) => { - let decoded = text.unescape().map_err(XmlError::new)?; + let decoded = text.decode().map_err(XmlError::new)?; result.push_str(""); @@ -145,11 +157,17 @@ pub fn atom_xhtml(reader: &mut Reader) -> Result, result.push_str(escape(decode(&text, reader)?.as_ref()).as_ref()); } Event::Text(text) => { - let decoded = text.unescape().map_err(XmlError::new)?; + let decoded = text.decode().map_err(XmlError::new)?; result.push_str(escape(decoded.as_ref()).as_ref()); } + Event::GeneralRef(gref) => { + let entity = gref.decode().map_err(XmlError::new)?; + result.push('&'); + result.push_str(&entity); + result.push(';'); + } Event::Comment(text) => { - let decoded = text.unescape().map_err(XmlError::new)?; + let decoded = text.decode().map_err(XmlError::new)?; result.push_str(""); From 9e79a7a37220ffeda2dfc1909be55d510c6011a5 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sun, 14 Sep 2025 13:52:35 +0200 Subject: [PATCH 3/3] Bump MSRV to 1.83.0 --- .github/workflows/build.yml | 2 +- CHANGELOG.md | 1 + Cargo.toml | 1 + README.md | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 39b5b65..fa578e1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: - nightly - beta - stable - - 1.57.0 + - 1.83.0 steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index a813d33..bbed29e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Enables the parsing of elements defined in another namespace in Person constructs [`#91`](https://github.com/rust-syndication/atom/pull/91) - Update `quick-xml` to `0.38` [`#92`](https://github.com/rust-syndication/atom/pull/92) +- Bump MSRV (Minimum Supported Rust Version) from 1.57.0 to 1.83.0 ## 0.12.7 - 2025-02-16 diff --git a/Cargo.toml b/Cargo.toml index 1ad161f..cf28d7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ license = "MIT/Apache-2.0" readme = "README.md" keywords = ["atom", "feed", "parser", "parsing"] categories = ["parser-implementations"] +rust-version = "1.83" [dependencies] diligent-date-parser = "0.1.3" diff --git a/README.md b/README.md index aafbf35..0c6fd60 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Library for serializing the Atom web content syndication format. [Documentation](https://docs.rs/atom_syndication/) -This crate requires *Rustc version 1.57.0 or greater*. +This crate requires *Rustc version 1.83.0 or greater*. ## Usage