diff src/http/modules/ngx_http_autoindex_module.c @ 492:98143f74eb3d NGINX_0_7_58

nginx 0.7.58 *) Feature: a "listen" directive of the mail proxy module supports IPv6. *) Feature: the "image_filter_jpeg_quality" directive. *) Feature: the "client_body_in_single_buffer" directive. *) Feature: the $request_body variable. *) Bugfix: in ngx_http_autoindex_module in file name links having a ":" symbol in the name. *) Bugfix: "make upgrade" procedure did not work; the bug had appeared in 0.7.53. Thanks to Denis F. Latypoff.
author Igor Sysoev <http://sysoev.ru>
date Mon, 18 May 2009 00:00:00 +0400
parents 549994537f15
children f39b9e29530d
line wrap: on
line diff
--- 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_requ
             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_requ
             + 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("&gt;") - 2
             + sizeof("</a>") - 1
             + sizeof(" 28-Sep-1970 12:00 ") - 1
@@ -396,6 +401,11 @@ ngx_http_autoindex_handler(ngx_http_requ
     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);