diff --git a/Cargo.lock b/Cargo.lock index 97d5c3a..77d09a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -203,7 +203,7 @@ dependencies = [ "serde_urlencoded", "smallvec", "socket2", - "time 0.3.9", + "time", "url 2.2.2", ] @@ -511,17 +511,14 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.22" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ "iana-time-zone", - "js-sys", "num-integer", "num-traits", "serde", - "time 0.1.44", - "wasm-bindgen", "winapi", ] @@ -611,7 +608,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05" dependencies = [ "percent-encoding 2.1.0", - "time 0.3.9", + "time", "version_check", ] @@ -2665,7 +2662,7 @@ dependencies = [ "serde", "siphasher", "thiserror", - "time 0.3.9", + "time", "tokio", "tokio-postgres", "toml", @@ -3082,7 +3079,7 @@ dependencies = [ "rand 0.8.4", "sha3", "thiserror", - "time 0.3.9", + "time", ] [[package]] @@ -3249,17 +3246,6 @@ dependencies = [ "syn", ] -[[package]] -name = "time" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - [[package]] name = "time" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 7f37f2e..f05d61d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ base64 = "0.13.0" # Used to decode base58btc bs58 = "0.4.0" # Used for working with dates -chrono = { version = "0.4.22", features = ["serde"] } +chrono = { version = "0.4.23", default-features = false, features = ["std", "serde"] } # Used to build admin CLI tool clap = { version = "3.2.18", default-features = false, features = ["std", "derive"] } # Used for parsing markdown diff --git a/src/atom/feeds.rs b/src/atom/feeds.rs index 291a4e1..1112d8e 100644 --- a/src/atom/feeds.rs +++ b/src/atom/feeds.rs @@ -10,7 +10,9 @@ use crate::utils::html::clean_html_all; const ENTRY_TITLE_MAX_LENGTH: usize = 75; fn get_min_datetime() -> DateTime { - DateTime::from_utc(NaiveDateTime::from_timestamp(0, 0), Utc) + let native = NaiveDateTime::from_timestamp_opt(0, 0) + .expect("0 should be a valid argument"); + DateTime::from_utc(native, Utc) } fn make_entry( diff --git a/src/http_signatures/verify.rs b/src/http_signatures/verify.rs index 0a955cd..755a94a 100644 --- a/src/http_signatures/verify.rs +++ b/src/http_signatures/verify.rs @@ -70,7 +70,8 @@ pub fn parse_http_signature( let created_at = if let Some(created_at) = signature_parameters.get("created") { let create_at_timestamp = created_at.parse() .map_err(|_| VerificationError::ParseError("invalid timestamp"))?; - Utc.timestamp(create_at_timestamp, 0) + Utc.timestamp_opt(create_at_timestamp, 0).single() + .ok_or(VerificationError::ParseError("invalid timestamp"))? } else { let date_str = request_headers.get("date") .ok_or(VerificationError::ParseError("missing date"))? @@ -83,7 +84,8 @@ pub fn parse_http_signature( let expires_at = if let Some(expires_at) = signature_parameters.get("expires") { let expires_at_timestamp = expires_at.parse() .map_err(|_| VerificationError::ParseError("invalid timestamp"))?; - Utc.timestamp(expires_at_timestamp, 0) + Utc.timestamp_opt(expires_at_timestamp, 0).single() + .ok_or(VerificationError::ParseError("invalid timestamp"))? } else { created_at + Duration::hours(SIGNATURE_EXPIRES_IN) };