Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Upgrade `base64` to v0.22 (#15304)
Marshall Bowerse423f03ba6d5
diff --git a/Cargo.lock b/Cargo.lockindex 95ec30aad93..8db15bb643f 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1484,12 +1484,6 @@ version = "0.1.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce"-[[package]]-name = "base64"-version = "0.13.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"-[[package]]name = "base64"version = "0.21.7"@@ -2454,7 +2448,7 @@ dependencies = ["aws-sdk-s3","axum","axum-extra",- "base64 0.13.1",+ "base64 0.22.0","call","channel","chrono",@@ -8708,7 +8702,7 @@ dependencies = ["alacritty_terminal 0.23.0","anyhow","async-dispatcher",- "base64 0.13.1",+ "base64 0.22.0","client","collections","command_palette_hooks",@@ -8932,7 +8926,7 @@ version = "0.1.0"dependencies = ["anyhow","async-tungstenite",- "base64 0.13.1",+ "base64 0.22.0","chrono","collections","env_logger",diff --git a/Cargo.toml b/Cargo.tomlindex 22f681f0788..fe1473a8cd2 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -316,7 +316,7 @@ async-trait = "0.1"async-tungstenite = "0.23"async-watch = "0.3.1"async_zip = { version = "0.0.17", features = ["deflate", "deflate64"] }-base64 = "0.13"+base64 = "0.22"bitflags = "2.6.0"blade-graphics = { git = "https://github.com/zed-industries/blade", rev = "7e497c534d5d4a30c18d9eb182cf39eaf0aaa25e" }blade-macros = { git = "https://github.com/zed-industries/blade", rev = "7e497c534d5d4a30c18d9eb182cf39eaf0aaa25e" }diff --git a/crates/collab/src/auth.rs b/crates/collab/src/auth.rsindex 35855adc289..261fe9b850f 100644--- a/crates/collab/src/auth.rs+++ b/crates/collab/src/auth.rs@@ -9,6 +9,7 @@ use axum::{middleware::Next,response::IntoResponse,};+use base64::prelude::*;use prometheus::{exponential_buckets, register_histogram, Histogram};pub use rpc::auth::random_token;use scrypt::{@@ -155,10 +156,7 @@ pub async fn create_access_token(/// protection.pub fn hash_access_token(token: &str) -> String {let digest = sha2::Sha256::digest(token);- format!(- "$sha256${}",- base64::encode_config(digest, base64::URL_SAFE)- )+ format!("$sha256${}", BASE64_URL_SAFE.encode(digest))}/// Encrypts the given access token with the given public key to avoid leaking it on the waydiff --git a/crates/repl/src/outputs.rs b/crates/repl/src/outputs.rsindex c48095b60b4..ab67425f0aa 100644--- a/crates/repl/src/outputs.rs+++ b/crates/repl/src/outputs.rs@@ -3,6 +3,7 @@ use std::time::Duration;use crate::stdio::TerminalOutput;use anyhow::Result;+use base64::prelude::*;use gpui::{img, percentage, Animation, AnimationExt, AnyElement, FontWeight, ImageData, Render, TextRun,Transformation, View,@@ -63,7 +64,7 @@ impl ImageView {}fn from(base64_encoded_data: &str) -> Result<Self> {- let bytes = base64::decode(base64_encoded_data)?;+ let bytes = BASE64_STANDARD.decode(base64_encoded_data)?;let format = image::guess_format(&bytes)?;let mut data = image::load_from_memory_with_format(&bytes, format)?.into_rgba8();diff --git a/crates/rpc/src/auth.rs b/crates/rpc/src/auth.rsindex 76d95b02ed0..32f8a1e047f 100644--- a/crates/rpc/src/auth.rs+++ b/crates/rpc/src/auth.rs@@ -1,4 +1,5 @@use anyhow::{Context, Result};+use base64::prelude::*;use rand::{thread_rng, Rng as _};use rsa::pkcs1::{DecodeRsaPublicKey, EncodeRsaPublicKey};use rsa::traits::PaddingScheme;@@ -44,7 +45,7 @@ pub fn random_token() -> String {for byte in token_bytes.iter_mut() {*byte = rng.gen();}- base64::encode_config(token_bytes, base64::URL_SAFE)+ BASE64_URL_SAFE.encode(token_bytes)}impl PublicKey {@@ -58,7 +59,7 @@ impl PublicKey {EncryptionFormat::V1 => self.0.encrypt(&mut rng, oaep_sha256_padding(), bytes),}.context("failed to encrypt string with public key")?;- let encrypted_string = base64::encode_config(&encrypted_bytes, base64::URL_SAFE);+ let encrypted_string = BASE64_URL_SAFE.encode(&encrypted_bytes);Ok(encrypted_string)}}@@ -66,7 +67,8 @@ impl PublicKey {impl PrivateKey {/// Decrypt a base64-encoded string that was encrypted by the corresponding public key.pub fn decrypt_string(&self, encrypted_string: &str) -> Result<String> {- let encrypted_bytes = base64::decode_config(encrypted_string, base64::URL_SAFE)+ let encrypted_bytes = BASE64_URL_SAFE+ .decode(encrypted_string).context("failed to base64-decode encrypted string")?;let bytes = self.0@@ -89,7 +91,7 @@ impl TryFrom<PublicKey> for String {.0.to_pkcs1_der().context("failed to serialize public key")?;- let string = base64::encode_config(&bytes, base64::URL_SAFE);+ let string = BASE64_URL_SAFE.encode(&bytes);Ok(string)}}@@ -97,7 +99,8 @@ impl TryFrom<PublicKey> for String {impl TryFrom<String> for PublicKey {type Error = anyhow::Error;fn try_from(value: String) -> Result<Self> {- let bytes = base64::decode_config(&value, base64::URL_SAFE)+ let bytes = BASE64_URL_SAFE+ .decode(&value).context("failed to base64-decode public key string")?;let key = Self(RsaPublicKey::from_pkcs1_der(&bytes).context("failed to parse public key")?);Ok(key)