Skip to content

Commit f44ee51

Browse files
committed
Treat empty path as /
Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent a2afd70 commit f44ee51

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

src/main.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,11 @@ async fn ax_post_file(
688688
path.pop();
689689
}
690690

691-
let full_path = format!("{}/{}", path, file0_filename);
691+
let full_path = if path.is_empty() {
692+
file0_filename.clone()
693+
} else {
694+
format!("{}/{}", path, file0_filename)
695+
};
692696

693697
// validate path for traversal
694698
match validate_path(&full_path) {
@@ -814,19 +818,16 @@ async fn ax_post_file(
814818
// Handle buffered file0 case (file0 arrived before path)
815819
if upload_result.is_none() {
816820
if let Some(tmp) = buffered_file {
817-
if path.is_empty() {
818-
return (
819-
StatusCode::BAD_REQUEST,
820-
b"Missing path field in upload".to_vec(),
821-
);
822-
}
823-
824821
if path.ends_with("/") {
825822
debug_log!("Removing trailing /, workaround");
826823
path.pop();
827824
}
828825

829-
let full_path = format!("{}/{}", path, file0_filename);
826+
let full_path = if path.is_empty() {
827+
file0_filename.clone()
828+
} else {
829+
format!("{}/{}", path, file0_filename)
830+
};
830831

831832
match validate_path(&full_path) {
832833
Ok(_) => (),

0 commit comments

Comments
 (0)