diff --git a/mongoose.c b/mongoose.c index 0143aaff..a7b14355 100644 --- a/mongoose.c +++ b/mongoose.c @@ -1381,8 +1381,10 @@ static void listdir(struct mg_connection *c, struct mg_http_message *hm, ""; struct mg_fs *fs = opts->fs == NULL ? &mg_fs_posix : opts->fs; struct printdirentrydata d = {c, hm, opts, dir}; - char tmp[10]; + char tmp[10], buf[MG_PATH_MAX]; size_t off, n; + int len = mg_url_decode(hm->uri.ptr, hm->uri.len, buf, sizeof(buf), 0); + struct mg_str uri = len > 0 ? mg_str_n(buf, (size_t) len) : hm->uri; mg_printf(c, "HTTP/1.1 200 OK\r\n" @@ -1402,8 +1404,8 @@ static void listdir(struct mg_connection *c, struct mg_http_message *hm, "
" "" "\n", - (int) hm->uri.len, hm->uri.ptr, sort_js_code, sort_js_code2, - (int) hm->uri.len, hm->uri.ptr); + (int) uri.len, uri.ptr, sort_js_code, sort_js_code2, (int) uri.len, + uri.ptr); fs->list(dir, printdirentry, &d); mg_printf(c, diff --git a/src/http.c b/src/http.c index 6b63e98b..3d531eee 100644 --- a/src/http.c +++ b/src/http.c @@ -632,8 +632,10 @@ static void listdir(struct mg_connection *c, struct mg_http_message *hm, ""; struct mg_fs *fs = opts->fs == NULL ? &mg_fs_posix : opts->fs; struct printdirentrydata d = {c, hm, opts, dir}; - char tmp[10]; + char tmp[10], buf[MG_PATH_MAX]; size_t off, n; + int len = mg_url_decode(hm->uri.ptr, hm->uri.len, buf, sizeof(buf), 0); + struct mg_str uri = len > 0 ? mg_str_n(buf, (size_t) len) : hm->uri; mg_printf(c, "HTTP/1.1 200 OK\r\n" @@ -653,8 +655,8 @@ static void listdir(struct mg_connection *c, struct mg_http_message *hm, "
" "" "\n", - (int) hm->uri.len, hm->uri.ptr, sort_js_code, sort_js_code2, - (int) hm->uri.len, hm->uri.ptr); + (int) uri.len, uri.ptr, sort_js_code, sort_js_code2, (int) uri.len, + uri.ptr); fs->list(dir, printdirentry, &d); mg_printf(c,