Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/modules/ngx_http_autoindex_handler.c')
-rw-r--r--src/http/modules/ngx_http_autoindex_handler.c38
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);