Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update base64 to 0.21 #127

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ members = [
[dependencies]
http = "0.2.0"
headers-core = { version = "0.2", path = "./headers-core" }
base64 = "0.13"
base64 = "0.21.3"
bytes = "1"
mime = "0.3.14"
sha1 = "0.10"
Expand Down
8 changes: 5 additions & 3 deletions src/common/authorization.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Authorization header and types.

use base64;
use base64::engine::general_purpose::STANDARD as ENGINE;
use base64::Engine;
use bytes::Bytes;

use util::HeaderValueString;
Expand Down Expand Up @@ -158,7 +159,8 @@ impl Credentials for Basic {
let bytes = &value.as_bytes()["Basic ".len()..];
let non_space_pos = bytes.iter().position(|b| *b != b' ')?;
let bytes = &bytes[non_space_pos..];
let bytes = base64::decode(bytes).ok()?;

let bytes = ENGINE.decode(bytes).ok()?;

let decoded = String::from_utf8(bytes).ok()?;

Expand All @@ -169,7 +171,7 @@ impl Credentials for Basic {

fn encode(&self) -> HeaderValue {
let mut encoded = String::from("Basic ");
base64::encode_config_buf(&self.decoded, base64::STANDARD, &mut encoded);
ENGINE.encode_string(&self.decoded, &mut encoded);

let bytes = Bytes::from(encoded);
HeaderValue::from_maybe_shared(bytes)
Expand Down
5 changes: 3 additions & 2 deletions src/common/sec_websocket_accept.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use base64;
use base64::engine::general_purpose::STANDARD as ENGINE;
use base64::Engine;
use bytes::Bytes;
use sha1::{Digest, Sha1};

Expand Down Expand Up @@ -39,7 +40,7 @@ fn sign(key: &[u8]) -> SecWebsocketAccept {
let mut sha1 = Sha1::default();
sha1.update(key);
sha1.update(&b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"[..]);
let b64 = Bytes::from(base64::encode(&sha1.finalize()));
let b64 = Bytes::from(ENGINE.encode(&sha1.finalize()));

let val = ::HeaderValue::from_maybe_shared(b64).expect("base64 is a valid value");

Expand Down