Opened 5 years ago

Last modified 4 years ago

#557 new enhancement

autoindex_show_hidden_files (autoindex feature option to show hidden files

Reported by: openid.sterneck.asia Owned by:
Priority: minor Milestone:
Component: nginx-module Version:
Keywords: autoindex Cc:
uname -a:
nginx -V: nginx version: nginx/1.6.0

Description

Attached a small patch to the autoindex module adding the option to choose whether to show hidden files or not.

The option can be set as follows:

syntax: autoindex_show_hidden_files on | off;
default: autoindex_show_hidden_files off;
context: http, server, location

Attachments (2)

ngx_autoindex_show_hidden_files.patch (2.2 KB) - added by openid.sterneck.asia 5 years ago.
patch to add feature to control visibility of hidden files when using the autoindex module
ngx_autoindex_show_dot_files.patch (2.4 KB) - added by openid.sterneck.asia 5 years ago.
patch to introduce new option for autoindex to show dot-files

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by openid.sterneck.asia

patch to add feature to control visibility of hidden files when using the autoindex module

Changed 5 years ago by openid.sterneck.asia

patch to introduce new option for autoindex to show dot-files

comment:1 Changed 5 years ago by openid.sterneck.asia

Because of the following disucssion/feedback in the forum, I have changed the option from "autoindex_show_hidden_files" to "autoindex_show_dot_files" to allow for some cross platform support (windows doesn't hide dot-files, so the word hidden does not make much sense here)

http://forum.nginx.org/read.php?2,216751,249931#msg-249931

New patch is attached to this document: "ngx_autoindex_show_dot_files.patch​"

comment:2 Changed 5 years ago by openid.sterneck.asia

the new syntax for this option is now:

syntax: autoindex_show_dot_files on | off;
default: autoindex_show_dot_files off;
context: http, server, location

comment:3 Changed 4 years ago by devzone.my@…

Very bad name for a variable, and very long. Breaks the syntax

autoindex_flags dot_files | hidden_files | empty;

autoindex_flags dot_files;
autoindex_flags dot_files hidden_files;

or
autoindex dot_files hidden_files;
autoindex on;

??

Last edited 4 years ago by devzone.my@… (previous) (diff)

comment:4 Changed 4 years ago by xiangzhai83@…

Hi Shin,

It is better to filter .. and .

diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c
index f694df0..e4f7b72 100644
--- a/src/http/modules/ngx_http_autoindex_module.c
+++ b/src/http/modules/ngx_http_autoindex_module.c
@@ -279,7 +279,8 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
 
         len = ngx_de_namelen(&dir);
 
-        if (ngx_de_name(&dir)[0] == '.') {
+        if ((ngx_de_name(&dir)[0] == '.' && len == 1) ||
+            (ngx_de_name(&dir)[0] == '.' && ngx_de_name(&dir)[1] == '.')) {
             continue;
         }
Note: See TracTickets for help on using tickets.