Mercurial > hg > nginx
changeset 2849:6a62bed048cd
fix colon in file name for ngx_http_autoindex_module
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 17 May 2009 19:01:23 +0000 |
parents | 0d8941f2b0ee |
children | 4e05bd832e56 |
files | src/http/modules/ngx_http_autoindex_module.c |
diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_autoindex_module.c Sat May 16 16:57:11 2009 +0000 +++ b/src/http/modules/ngx_http_autoindex_module.c Sun May 17 19:01:23 2009 +0000 @@ -25,8 +25,11 @@ 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 @@ 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 @@ + 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("</a>") - 1 + sizeof(" 28-Sep-1970 12:00 ") - 1 @@ -396,6 +401,11 @@ for (i = 0; i < entries.nelts; i++) { b->last = ngx_cpymem(b->last, "<a href=\"", sizeof("<a href=\"") - 1); + if (entry[i].colon) { + *b->last++ = '.'; + *b->last++ = '/'; + } + if (entry[i].escape) { ngx_escape_uri(b->last, entry[i].name.data, entry[i].name.len, NGX_ESCAPE_HTML);