From 505a566c7cf6c1db94f85f1757736c2e3446b962 Mon Sep 17 00:00:00 2001 From: Cocoon-Break <54054995+kuishou68@users.noreply.github.com> Date: Mon, 13 Apr 2026 18:42:50 +0800 Subject: [PATCH] fix: remove dead replace() call in gen_secret_key (credentials.rs) (#2515) Signed-off-by: cocoon <54054995+kuishou68@users.noreply.github.com> Signed-off-by: Cocoon-Break <54054995+kuishou68@users.noreply.github.com> Co-authored-by: loverustfs Co-authored-by: houseme --- crates/credentials/src/credentials.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/credentials/src/credentials.rs b/crates/credentials/src/credentials.rs index 0b97ff326..5346b5082 100644 --- a/crates/credentials/src/credentials.rs +++ b/crates/credentials/src/credentials.rs @@ -204,10 +204,11 @@ pub fn gen_secret_key(length: usize) -> std::io::Result { let mut key = vec![0u8; URL_SAFE_NO_PAD.estimated_decoded_length(length)]; rng.fill_bytes(&mut key); + // URL_SAFE_NO_PAD uses "-" and "_" instead of "+" and "/", so "/" never + // appears in the output. The .replace("/", "+") was a dead no-op. let encoded = URL_SAFE_NO_PAD.encode_to_string(&key); - let key_str = encoded.replace("/", "+"); - Ok(key_str) + Ok(encoded) } /// Get the RPC authentication token from environment variable