diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-05-17 19:01:23 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-05-17 19:01:23 +0000 |
commit | 7f20c49059c22f388a04fb9ef9453bc0d193cec8 (patch) | |
tree | d9bb28efa14ae71c996be9133943c671d7e8d5c7 /src | |
parent | 640e3a49d5b5b0bfaa9fe0200a9960a715ae8319 (diff) | |
download | nginx-7f20c49059c22f388a04fb9ef9453bc0d193cec8.tar.gz nginx-7f20c49059c22f388a04fb9ef9453bc0d193cec8.zip |
fix colon in file name for ngx_http_autoindex_module
Diffstat (limited to 'src')
-rw-r--r-- | src/http/modules/ngx_http_autoindex_module.c | 16 |
1 files changed, 13 insertions, 3 deletions
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("</a>") - 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, "<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); |