main.c: URL-encode created directories
Otherwise, directories with special characters, such as "%", would not be accessible when performing the redirection.
This commit is contained in:
parent
a578ad6537
commit
1f8aa578a4
9
main.c
9
main.c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue