Skip to content

Commit

Permalink
Add reserved namespace bindings.
Browse files Browse the repository at this point in the history
This adds xml and xmlns namespace bindings. These are defined at
https://www.w3.org/TR/xml-names11/#xmlReserved.
  • Loading branch information
wt committed Aug 25, 2023
1 parent 1be35e1 commit 9887b68
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@1.52.0
- uses: dtolnay/rust-toolchain@1.53.0
- run: cargo check

minimal-versions:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository = "https://github.com/tafia/quick-xml"
keywords = ["xml", "serde", "parser", "writer", "html"]
categories = ["asynchronous", "encoding", "parsing", "parser-implementations"]
license = "MIT"
rust-version = "1.52"
rust-version = "1.53"
include = ["src/*", "LICENSE-MIT.md", "README.md"]

[dependencies]
Expand Down
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@

### New Features

- [#541]: Deserialize specially named `$text` enum variant in [externally tagged]
enums from textual content
- [#545]: Resolve well-known namespaces (xml and xmlns) to their approrpriate URIs.
Also, enforce namespace constraints related to these well-known namespaces.

### Bug Fixes

### Misc Changes

- [#541]: Updated MSRV to 1.53 due to https://doc.rust-lang.org/edition-guide/rust-2021/IntoIterator-for-arrays.html

## 0.30.0 -- 2023-07-23

Expand Down
13 changes: 12 additions & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ use std::str::Utf8Error;
use std::string::FromUtf8Error;
use std::sync::Arc;

#[derive(Clone, Debug)]
pub struct ReservedNamespaceError {
pub prefix: String,
pub name: String,
}

/// The error type used by this crate.
#[derive(Clone, Debug)]
pub enum Error {
Expand Down Expand Up @@ -45,6 +51,8 @@ pub enum Error {
InvalidAttr(AttrError),
/// Escape error
EscapeError(EscapeError),
/// Error for when a reserved namespace is set incorrectly
ReservedNamespaceError(ReservedNamespaceError),
/// Specified namespace prefix is unknown, cannot resolve namespace for it
UnknownPrefix(Vec<u8>),
}
Expand Down Expand Up @@ -120,7 +128,10 @@ impl fmt::Display for Error {
f.write_str("Unknown namespace prefix '")?;
write_byte_string(f, prefix)?;
f.write_str("'")
}
},
Error::ReservedNamespaceError(e) => write!(
f, "The namespace prefix `{}` with name `{}` is invalid.", e.prefix, e.name
),
}
}
}
Expand Down
Loading

0 comments on commit 9887b68

Please sign in to comment.