From 4cd80a3df22cc1e624bcabc23ad8fb46f926d626 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Fri, 27 Jan 2023 22:25:05 +0100 Subject: [PATCH] Update toml lib Closes #1313 --- Cargo.lock | 56 ++++++++++++++++++++- components/content/src/front_matter/page.rs | 12 ++--- components/libs/Cargo.toml | 2 +- 3 files changed, 61 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc17679e..81f8ecc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1703,7 +1703,7 @@ dependencies = [ "tera", "termcolor", "time", - "toml", + "toml 0.7.0", "unic-langid", "unicode-segmentation", "url", @@ -2257,6 +2257,15 @@ dependencies = [ "syn", ] +[[package]] +name = "nom8" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" +dependencies = [ + "memchr", +] + [[package]] name = "nom_locate" version = "1.0.0" @@ -3221,6 +3230,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c68e921cef53841b8925c2abadd27c9b891d9613bdc43d6b823062866df38e8" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3706,6 +3724,40 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f560bc7fb3eb31f5eee1340c68a2160cad39605b7b9c9ec32045ddbdee13b85" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "886f31a9b85b6182cabd4d8b07df3b451afcc216563748201490940d2a28ed36" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233d8716cdc5d20ec88a18a839edaf545edc71efa4a5ff700ef4a102c26cd8fa" +dependencies = [ + "indexmap", + "nom8", + "serde", + "serde_spanned", + "toml_datetime", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -4179,7 +4231,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c" dependencies = [ - "toml", + "toml 0.5.11", ] [[package]] diff --git a/components/content/src/front_matter/page.rs b/components/content/src/front_matter/page.rs index ac4c69a7..60d8f756 100644 --- a/components/content/src/front_matter/page.rs +++ b/components/content/src/front_matter/page.rs @@ -392,20 +392,20 @@ title = "Hello" description = "hey there" [extra] -some-date = 2002-14-01 +some-date = 2002-11-01 "#); "toml")] #[test_case(&RawFrontMatter::Yaml(r#" title: Hello description: hey there extra: - some-date: 2002-14-01 + some-date: 2002-11-01 "#); "yaml")] fn can_parse_dates_in_extra(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); println!("{:?}", res); assert!(res.is_ok()); - assert_eq!(res.unwrap().extra["some-date"], to_value("2002-14-01").unwrap()); + assert_eq!(res.unwrap().extra["some-date"], to_value("2002-11-01").unwrap()); } #[test_case(&RawFrontMatter::Toml(r#" @@ -413,7 +413,7 @@ title = "Hello" description = "hey there" [extra.something] -some-date = 2002-14-01 +some-date = 2002-11-01 "#); "toml")] #[test_case(&RawFrontMatter::Yaml(r#" title: Hello @@ -421,13 +421,13 @@ description: hey there extra: something: - some-date: 2002-14-01 + some-date: 2002-11-01 "#); "yaml")] fn can_parse_nested_dates_in_extra(content: &RawFrontMatter) { let res = PageFrontMatter::parse(content); println!("{:?}", res); assert!(res.is_ok()); - assert_eq!(res.unwrap().extra["something"]["some-date"], to_value("2002-14-01").unwrap()); + assert_eq!(res.unwrap().extra["something"]["some-date"], to_value("2002-11-01").unwrap()); } #[test_case(&RawFrontMatter::Toml(r#" diff --git a/components/libs/Cargo.toml b/components/libs/Cargo.toml index 58c9b8f0..2eb8bf8a 100644 --- a/components/libs/Cargo.toml +++ b/components/libs/Cargo.toml @@ -37,7 +37,7 @@ syntect = "5" tera = { version = "1.17", features = ["preserve_order", "date-locale"] } termcolor = "1.0.4" time = "0.3" -toml = "0.5" +toml = "0.7" unic-langid = "0.9" unicode-segmentation = "1.2" url = "2"