diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-02-19 23:07:16 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-02-19 23:35:08 +0100 |
| commit | 1f8aa578a489905ed2d7443cfcdb73a3ff8d48ea (patch) | |
| tree | 85b6319076dfa36e349962390419e4c3e1e4b9c3 | |
| parent | a578ad6537320e562ce936bf70426ab2820ddaad (diff) | |
| download | slcl-1f8aa578a489905ed2d7443cfcdb73a3ff8d48ea.tar.gz | |
main.c: URL-encode created directories
Otherwise, directories with special characters, such as "%", would not
be accessible when performing the redirection.
| -rw-r--r-- | main.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1356,6 +1356,7 @@ static int createdir(const struct http_payload *const p, struct dynstr d, userd; struct form *forms = NULL; size_t n = 0; + char *encurl = NULL; dynstr_init(&d); dynstr_init(&userd); @@ -1469,7 +1470,12 @@ static int createdir(const struct http_payload *const p, .status = HTTP_STATUS_SEE_OTHER }; - if (http_response_add_header(r, "Location", userd.str)) + if (!(encurl = http_encode_url(userd.str))) + { + fprintf(stderr, "%s: http_encode_url failed\n", __func__); + goto end; + } + else if (http_response_add_header(r, "Location", encurl)) { fprintf(stderr, "%s: http_response_add_header failed\n", __func__); goto end; @@ -1482,6 +1488,7 @@ end: forms_free(forms, n); dynstr_free(&userd); dynstr_free(&d); + free(encurl); return ret; } |
