Skip to content

Commit

Permalink
Unescape filename
Browse files Browse the repository at this point in the history
  • Loading branch information
杨赫然 committed Sep 18, 2024
1 parent 72753e1 commit fc69cb9
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit fc69cb9

Please sign in to comment.