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 6a7a543
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 27 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
22 changes: 21 additions & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ use std::str::Utf8Error;
use std::string::FromUtf8Error;
use std::sync::Arc;

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

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

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

0 comments on commit 6a7a543

Please sign in to comment.