Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unescape filename #701

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions server/access-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,7 @@ access_cb(evhtp_request_t *req, void *arg)
char *error = NULL;
char *token = NULL;
char *filename = NULL;
char *dec_filename = NULL;
const char *repo_id = NULL;
const char *data = NULL;
const char *operation = NULL;
Expand All @@ -1386,6 +1387,9 @@ access_cb(evhtp_request_t *req, void *arg)
token = parts[1];
filename = parts[2];

// The filename is url-encoded.
dec_filename = g_uri_unescape_string(filename, NULL);

webaccess = seaf_web_at_manager_query_access_token (seaf->web_at_mgr, token);
if (!webaccess) {
error = "Access token not found";
Expand Down Expand Up @@ -1436,18 +1440,19 @@ access_cb(evhtp_request_t *req, void *arg)
}

if (!repo->encrypted && byte_ranges) {
if (do_file_range (req, repo, data, filename, operation, byte_ranges, user) < 0) {
if (do_file_range (req, repo, data, dec_filename, operation, byte_ranges, user) < 0) {
error = "Internal server error\n";
error_code = EVHTP_RES_SERVERR;
goto on_error;
}
} else if (do_file(req, repo, data, filename, operation, key, user) < 0) {
} else if (do_file(req, repo, data, dec_filename, operation, key, user) < 0) {
error = "Internal server error\n";
error_code = EVHTP_RES_SERVERR;
goto on_error;
}

success:
g_free (dec_filename);
g_strfreev (parts);
if (repo != NULL)
seaf_repo_unref (repo);
Expand All @@ -1459,6 +1464,7 @@ access_cb(evhtp_request_t *req, void *arg)
return;

on_error:
g_free (dec_filename);
g_strfreev (parts);
if (repo != NULL)
seaf_repo_unref (repo);
Expand Down
Loading