diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-10-26 06:27:24 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-10-26 06:27:24 +0000 |
commit | 1405efbe2f15d04f5b970f48c5f670bb061a730c (patch) | |
tree | fe0f15462a40dc2b9e005a943720d51fb924a193 /src/http/modules/ngx_http_autoindex_handler.c | |
parent | 66d28f5f5935601c83fd9b5e9569e87a985c82fc (diff) | |
download | nginx-release-0.1.4.tar.gz nginx-release-0.1.4.zip |
nginx-0.1.4-RELEASE importrelease-0.1.4
*) Bugfix: in the ngx_http_autoindex_module.
Diffstat (limited to 'src/http/modules/ngx_http_autoindex_handler.c')
-rw-r--r-- | src/http/modules/ngx_http_autoindex_handler.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/http/modules/ngx_http_autoindex_handler.c b/src/http/modules/ngx_http_autoindex_handler.c index 5f1726efc..99aa35d88 100644 --- a/src/http/modules/ngx_http_autoindex_handler.c +++ b/src/http/modules/ngx_http_autoindex_handler.c @@ -230,6 +230,17 @@ static ngx_int_t ngx_http_autoindex_handler(ngx_http_request_t *r) len = ngx_de_namelen(&dir); + if (len == 1 && ngx_de_name(&dir)[0] == '.') { + continue; + } + + if (len == 2 + && ngx_de_name(&dir)[0] == '.' + && ngx_de_name(&dir)[0] == '.') + { + continue; + } + if (!dir.valid_info) { if (dname.len + 1 + len > fname.len) { @@ -253,17 +264,6 @@ static ngx_int_t ngx_http_autoindex_handler(ngx_http_request_t *r) } } - if (len == 1 && ngx_de_name(&dir)[0] == '.') { - continue; - } - - if (len == 2 - && ngx_de_name(&dir)[0] == '.' - && ngx_de_name(&dir)[0] == '.') - { - continue; - } - if (!(entry = ngx_array_push(&entries))) { return ngx_http_autoindex_error(r, &dir, dname.data); } @@ -375,24 +375,24 @@ static ngx_int_t ngx_http_autoindex_handler(ngx_http_request_t *r) } else { length = entry[i].size; - if (length > 999999999) { - size = (ngx_int_t) length / 1024 * 1024 * 1024; - if ((length % 1024 * 1024 * 1024) + if (length > 1024 * 1024 * 1024) { + size = (ngx_int_t) (length / (1024 * 1024 * 1024)); + if ((length % (1024 * 1024 * 1024)) > (1024 * 1024 * 1024 / 2 - 1)) { size++; } scale = 'G'; - } else if (length > 999999) { - size = (ngx_int_t) length / 1024 * 1024; - if ((length % 1024 * 1024) > (1024 * 1024 / 2 - 1)) { + } else if (length > 1024 * 1024) { + size = (ngx_int_t) (length / (1024 * 1024)); + if ((length % (1024 * 1024)) > (1024 * 1024 / 2 - 1)) { size++; } scale = 'M'; } else if (length > 9999) { - size = (ngx_int_t) length / 1024; + size = (ngx_int_t) (length / 1024); if (length % 1024 > 511) { size++; } @@ -414,6 +414,8 @@ static ngx_int_t ngx_http_autoindex_handler(ngx_http_request_t *r) *b->last++ = LF; } + /* TODO: free temporary pool */ + b->last = ngx_cpymem(b->last, "</pre><hr>", sizeof("</pre><hr>") - 1); b->last = ngx_cpymem(b->last, tail, sizeof(tail) - 1); |