@@ -15,6 +15,7 @@ use crate::streams::multipart::{self, Multipart};
15
15
use crate :: utils:: { crypto, Apply } ;
16
16
use crate :: { Body , BoxStdError , Method , Mime , Request , Response } ;
17
17
18
+ use std:: borrow:: Cow ;
18
19
use std:: fmt:: { self , Debug } ;
19
20
use std:: io;
20
21
use std:: mem;
@@ -143,7 +144,8 @@ impl S3Service {
143
144
/// Returns an `Err` if any component failed
144
145
pub async fn handle ( & self , mut req : Request ) -> S3Result < Response > {
145
146
let body = mem:: take ( req. body_mut ( ) ) ;
146
- let path = extract_s3_path ( & req) ?;
147
+ let uri_path = decode_uri_path ( & req) ?;
148
+ let path = extract_s3_path ( & uri_path) ?;
147
149
let headers = extract_headers ( & req) ?;
148
150
let query_strings = extract_qs ( & req) ?;
149
151
let mime = extract_mime ( & headers) ?;
@@ -177,9 +179,15 @@ impl S3Service {
177
179
}
178
180
}
179
181
182
+ /// Extract urlencoded URI from Request
183
+ fn decode_uri_path ( req : & Request ) -> S3Result < Cow < ' _ , str > > {
184
+ urlencoding:: decode ( req. uri ( ) . path ( ) )
185
+ . map_err ( |e| code_error ! ( InvalidURI , "Cannot url decode uri path" , e) )
186
+ }
187
+
180
188
/// util function
181
- fn extract_s3_path ( req : & Request ) -> S3Result < S3Path < ' _ > > {
182
- let result = S3Path :: try_from_path ( req . uri ( ) . path ( ) ) ;
189
+ fn extract_s3_path ( uri_path : & str ) -> S3Result < S3Path < ' _ > > {
190
+ let result = S3Path :: try_from_path ( uri_path ) ;
183
191
let err = try_err ! ( result) ;
184
192
let ( code, msg) = match * err. kind ( ) {
185
193
S3PathErrorKind :: InvalidPath => {
0 commit comments