From 34677a5fa11aba1c15a7b0e47cec88f644cd3d90 Mon Sep 17 00:00:00 2001 From: Kevin Cox Date: Tue, 19 Jul 2022 07:47:46 -0400 Subject: [PATCH] Switch to hard-xml. (#4) strong-xml is unmaintained and this fork includes a fix to a self-closing element causing a parse error. This also fixes a build-time warning with the strong-xml derive macro. --- Cargo.lock | 50 +++++++++++++------------- opml_api/Cargo.toml | 2 +- opml_api/source/lib.rs | 4 +-- opml_api/tests/samples/empty_docs.opml | 8 +++++ opml_api/tests/valid.rs | 23 ++++++++++++ 5 files changed, 59 insertions(+), 28 deletions(-) create mode 100644 opml_api/tests/samples/empty_docs.opml diff --git a/Cargo.lock b/Cargo.lock index b69a554..ac592ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,6 +86,30 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +[[package]] +name = "hard-xml" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c049a5d5186e83c3cf139192e81ab9d06c6b20d18c8aa06b38f3f6a5ece8703" +dependencies = [ + "hard-xml-derive", + "jetscii", + "lazy_static", + "memchr", + "xmlparser", +] + +[[package]] +name = "hard-xml-derive" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24cec6f13bd2423158425bdb5f5ba0f2ddf7d7c2a825c0fdbf20c513df49725" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "hermit-abi" version = "0.1.15" @@ -138,8 +162,8 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" name = "opml" version = "1.1.3" dependencies = [ + "hard-xml", "serde", - "strong-xml", "thiserror", ] @@ -242,30 +266,6 @@ dependencies = [ "serde", ] -[[package]] -name = "strong-xml" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d19fb3a618e2f1039e32317c9f525e6d45c55af704ec7c429aa74412419bebf" -dependencies = [ - "jetscii", - "lazy_static", - "memchr", - "strong-xml-derive", - "xmlparser", -] - -[[package]] -name = "strong-xml-derive" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92c781f499321613b112be5d9338189ef1ed19689a01edd23d923ea57ad5c7e1" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "strsim" version = "0.8.0" diff --git a/opml_api/Cargo.toml b/opml_api/Cargo.toml index 129f1a7..5f26099 100644 --- a/opml_api/Cargo.toml +++ b/opml_api/Cargo.toml @@ -15,7 +15,7 @@ keywords = ["xml", "opml"] path = "source/lib.rs" [dependencies] -strong-xml = "0.6.3" +hard-xml = "1.10.0" thiserror = "1.0.29" [dependencies.serde] diff --git a/opml_api/source/lib.rs b/opml_api/source/lib.rs index 3ad5e4d..456200b 100644 --- a/opml_api/source/lib.rs +++ b/opml_api/source/lib.rs @@ -30,7 +30,7 @@ //! old `OPML { /* ... */ }` syntax. use serde::{Deserialize, Serialize}; -use strong_xml::{XmlRead, XmlWrite}; +use hard_xml::{XmlRead, XmlWrite}; use thiserror::Error; /// All possible errors. @@ -52,7 +52,7 @@ pub enum Error { /// The input string is not valid XML. #[error("Failed to process XML file")] - XmlError(#[from] strong_xml::XmlError), + XmlError(#[from] hard_xml::XmlError), } /// The top-level [`OPML`] element. diff --git a/opml_api/tests/samples/empty_docs.opml b/opml_api/tests/samples/empty_docs.opml new file mode 100644 index 0000000..05b0bc0 --- /dev/null +++ b/opml_api/tests/samples/empty_docs.opml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/opml_api/tests/valid.rs b/opml_api/tests/valid.rs index 0af4864..fc19b0f 100644 --- a/opml_api/tests/valid.rs +++ b/opml_api/tests/valid.rs @@ -20,6 +20,29 @@ fn test_minimum_valid_opml() { ); } +#[test] +fn test_valid_empty_docs() { + assert_eq!( + OPML::from_str( + &read("tests/samples/empty_docs.opml").unwrap() + ) + .unwrap(), + OPML { + version: "2.0".to_string(), + head: Some(Head { + docs: Some("".to_string()), + ..Head::default() + }), + body: Body { + outlines: vec![Outline { + text: "Outline Text".to_string(), + ..Outline::default() + }] + }, + } + ) +} + #[test] fn test_valid_opml_with_everything() { assert_eq!(