From 3686f100b7e46d60758e4a1cc70586444ddb5f7a Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 28 Apr 2020 10:35:04 +0000 Subject: [PATCH] Compatibility fixes --- src/api/api_server.rs | 8 +------- src/api/s3_list.rs | 6 ++++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/api/api_server.rs b/src/api/api_server.rs index 6ba5e532..af331a39 100644 --- a/src/api/api_server.rs +++ b/src/api/api_server.rs @@ -226,13 +226,7 @@ async fn handler_inner( } fn parse_bucket_key(path: &str) -> Result<(&str, Option<&str>), Error> { - if !path.starts_with('/') { - return Err(Error::BadRequest(format!( - "Invalid path: {}, should start with a /", - path - ))); - } - let path = &path[1..]; + let path = path.trim_start_matches('/'); match path.find('/') { Some(i) => Ok((&path[..i], Some(&path[i + 1..]))), diff --git a/src/api/s3_list.rs b/src/api/s3_list.rs index 88f76771..ffde609f 100644 --- a/src/api/s3_list.rs +++ b/src/api/s3_list.rs @@ -103,7 +103,8 @@ pub async fn handle_list( writeln!( &mut xml, "\t\t{}", - xml_encode_key(key, urlencode_resp) + xml_escape(key), + //xml_encode_key(key, urlencode_resp) // doesn't work with nextcloud, wtf ) .unwrap(); writeln!(&mut xml, "\t\t{}", last_modif).unwrap(); @@ -117,7 +118,8 @@ pub async fn handle_list( writeln!( &mut xml, "\t{}", - xml_encode_key(pfx, urlencode_resp) + xml_escape(pfx), + //xml_encode_key(pfx, urlencode_resp) ) .unwrap(); }