From 9ec28cb491fa5f3c873d594c8b59232f2abff063 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Fri, 16 Dec 2022 11:21:37 +0100 Subject: [PATCH 1/2] Update base64 This updates base64 to the latest version. --- Cargo.toml | 2 +- src/common/authorization.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b49c86e7..7faec001 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ members = [ [dependencies] http = "0.2.0" headers-core = { version = "0.2", path = "./headers-core" } -base64 = "0.13" +base64 = "0.20" bitflags = "1.0" bytes = "1" mime = "0.3.14" diff --git a/src/common/authorization.rs b/src/common/authorization.rs index 734bc6e2..9c8c06a9 100644 --- a/src/common/authorization.rs +++ b/src/common/authorization.rs @@ -1,6 +1,10 @@ //! Authorization header and types. -use base64; +use base64::{ + self, + engine::fast_portable::{FastPortable, FastPortableConfig}, + alphabet::STANDARD, +}; use bytes::Bytes; use util::HeaderValueString; @@ -168,8 +172,10 @@ impl Credentials for Basic { } fn encode(&self) -> HeaderValue { + const ENGINE: FastPortable = FastPortable::from(&STANDARD, FastPortableConfig::new()); + let mut encoded = String::from("Basic "); - base64::encode_config_buf(&self.decoded, base64::STANDARD, &mut encoded); + base64::encode_engine_string(&self.decoded, &mut encoded, &ENGINE); let bytes = Bytes::from(encoded); HeaderValue::from_maybe_shared(bytes) From 1e27e281bf6ea52d444fda3b091921ebcd8aee4d Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Fri, 16 Dec 2022 11:28:41 +0100 Subject: [PATCH 2/2] Use `DEFAULT_ENGINE` --- src/common/authorization.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/common/authorization.rs b/src/common/authorization.rs index 9c8c06a9..0292eb25 100644 --- a/src/common/authorization.rs +++ b/src/common/authorization.rs @@ -1,10 +1,5 @@ //! Authorization header and types. -use base64::{ - self, - engine::fast_portable::{FastPortable, FastPortableConfig}, - alphabet::STANDARD, -}; use bytes::Bytes; use util::HeaderValueString; @@ -172,7 +167,7 @@ impl Credentials for Basic { } fn encode(&self) -> HeaderValue { - const ENGINE: FastPortable = FastPortable::from(&STANDARD, FastPortableConfig::new()); + const ENGINE: base64::engine::fast_portable::FastPortable = base64::engine::DEFAULT_ENGINE; let mut encoded = String::from("Basic "); base64::encode_engine_string(&self.decoded, &mut encoded, &ENGINE);