You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2026/08/14 18:09:51 UTC

(opendal) branch main updated: fix(services/b2): percent-encode the object path in presigned requests (#8076)

This is an automated email from the ASF dual-hosted git repository.

Xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 2988850a9 fix(services/b2): percent-encode the object path in presigned requests (#8076)
2988850a9 is described below

commit 2988850a9322bb357c7731e2211f979866b430e7
Author: ZIHAN DAI <99...@users.noreply.github.com>
AuthorDate: Sat Aug 15 04:09:44 2026 +1000

    fix(services/b2): percent-encode the object path in presigned requests (#8076)
---
 core/services/b2/src/backend.rs | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/core/services/b2/src/backend.rs b/core/services/b2/src/backend.rs
index 27e1cb6cf..7675a411e 100644
--- a/core/services/b2/src/backend.rs
+++ b/core/services/b2/src/backend.rs
@@ -374,7 +374,10 @@ impl Service for B2Backend {
 
                 let url = format!(
                     "{}/file/{}/{}?Authorization={}",
-                    auth_info.download_url, self.core.bucket, path, resp.authorization_token
+                    auth_info.download_url,
+                    self.core.bucket,
+                    percent_encode_path(&path),
+                    resp.authorization_token
                 );
 
                 let req = Request::get(url);
@@ -401,7 +404,10 @@ impl Service for B2Backend {
 
                 let url = format!(
                     "{}/file/{}/{}?Authorization={}",
-                    auth_info.download_url, self.core.bucket, path, resp.authorization_token
+                    auth_info.download_url,
+                    self.core.bucket,
+                    percent_encode_path(&path),
+                    resp.authorization_token
                 );
 
                 let req = Request::get(url);
@@ -423,7 +429,10 @@ impl Service for B2Backend {
                 let mut req = Request::post(&resp.upload_url);
 
                 req = req.header(http::header::AUTHORIZATION, resp.authorization_token);
-                req = req.header("X-Bz-File-Name", build_abs_path(&self.core.root, path));
+                req = req.header(
+                    "X-Bz-File-Name",
+                    percent_encode_path(&build_abs_path(&self.core.root, path)),
+                );
                 req = req.header(http::header::CONTENT_TYPE, "b2/x-auto");
                 req = req.header(constants::X_BZ_CONTENT_SHA1, "do_not_verify");