diff --git a/unsupported/juno/crates/juno_support/Cargo.toml b/unsupported/juno/crates/juno_support/Cargo.toml index 7b088d7d6fd..0d4dc387f7c 100644 --- a/unsupported/juno/crates/juno_support/Cargo.toml +++ b/unsupported/juno/crates/juno_support/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT" [dependencies] libcplusplus = { path = "../libcplusplus" } -base64 = "0.13" +base64 = "0.21.7" anyhow = "1.0" thiserror = "1.0" url = "2.2.2" diff --git a/unsupported/juno/crates/juno_support/src/fetchurl.rs b/unsupported/juno/crates/juno_support/src/fetchurl.rs index 62c8ec77b1f..3d81496bd54 100644 --- a/unsupported/juno/crates/juno_support/src/fetchurl.rs +++ b/unsupported/juno/crates/juno_support/src/fetchurl.rs @@ -18,10 +18,21 @@ use std::fs::File; use std::io::Read; use anyhow; -use base64; +use base64::alphabet::URL_SAFE; +use base64::engine::general_purpose::GeneralPurpose; +use base64::engine::general_purpose::GeneralPurposeConfig; +use base64::engine::general_purpose::PAD; +use base64::engine::DecodePaddingMode; +use base64::Engine; use thiserror; use url::Url; +// Bring back the pre 0.20 bevahiour and allow either padded or un-padded base64 strings at decode time. +const URL_SAFE_INDIFFERENT: GeneralPurpose = GeneralPurpose::new( + &URL_SAFE, + PAD.with_decode_padding_mode(DecodePaddingMode::Indifferent), +); + #[derive(thiserror::Error, Debug)] pub enum FetchError { #[error("URL parse error")] @@ -125,7 +136,7 @@ fn fetch_data(url: &Url) -> Result { return Err(FetchError::InvalidURL("data URL unsupported encoding")); } - let buf = base64::decode_config(data, base64::URL_SAFE).map_err(|e| { + let buf: Vec = URL_SAFE_INDIFFERENT.decode(data).map_err(|e| { FetchError::DecodeError(anyhow::anyhow!(e).context("error decoding data URL")) })?;