diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c index c866c43a6..6215da21f 100644 --- a/src/http/modules/ngx_http_autoindex_module.c +++ b/src/http/modules/ngx_http_autoindex_module.c @@ -25,8 +25,11 @@ typedef struct { typedef struct { ngx_str_t name; size_t utf_len; - ngx_uint_t escape; - ngx_uint_t dir; + size_t escape; + + unsigned dir:1; + unsigned colon:1; + time_t mtime; off_t size; } ngx_http_autoindex_entry_t; @@ -338,6 +341,8 @@ ngx_http_autoindex_handler(ngx_http_request_t *r) entry->utf_len = len; } + entry->colon = (ngx_strchr(entry->name.data, ':') != NULL); + entry->dir = ngx_de_is_dir(&dir); entry->mtime = ngx_de_mtime(&dir); entry->size = ngx_de_size(&dir); @@ -363,7 +368,7 @@ ngx_http_autoindex_handler(ngx_http_request_t *r) + entry[i].name.len + entry[i].escape + 1 /* 1 is for "/" */ + sizeof("\">") - 1 - + entry[i].name.len - entry[i].utf_len + + entry[i].name.len - entry[i].utf_len + entry[i].colon * 2 + NGX_HTTP_AUTOINDEX_NAME_LEN + sizeof(">") - 2 + sizeof("") - 1 + sizeof(" 28-Sep-1970 12:00 ") - 1 @@ -396,6 +401,11 @@ ngx_http_autoindex_handler(ngx_http_request_t *r) for (i = 0; i < entries.nelts; i++) { b->last = ngx_cpymem(b->last, "last++ = '.'; + *b->last++ = '/'; + } + if (entry[i].escape) { ngx_escape_uri(b->last, entry[i].name.data, entry[i].name.len, NGX_ESCAPE_HTML);