Index: src/config.c =================================================================== --- src/config.c (revision 107) +++ src/config.c (working copy) @@ -74,6 +74,7 @@ { "dir-listing.hide-dotfiles", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 39 */ { "dir-listing.external-css", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 40 */ + { "dir-listing.hide", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 41 */ { "server.host", "use server.bind instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET }, { "server.docroot", "use server.document-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET }, @@ -120,6 +121,7 @@ s->hide_dotfiles = 1; s->indexfiles = array_init(); s->mimetypes = array_init(); + s->dirlist_hide = array_init(); s->server_name = buffer_init(); s->ssl_pemfile = buffer_init(); s->ssl_ca_file = buffer_init(); @@ -173,6 +175,7 @@ cv[38].destination = s->ssl_ca_file; cv[39].destination = &(s->hide_dotfiles); cv[40].destination = s->dirlist_css; + cv[41].destination = s->dirlist_hide; srv->config_storage[i] = s; @@ -196,6 +199,7 @@ PATCH(dir_listing); PATCH(dirlist_css); PATCH(hide_dotfiles); + PATCH(dirlist_hide); PATCH(indexfiles); PATCH(max_keep_alive_requests); PATCH(max_keep_alive_idle); @@ -245,6 +249,8 @@ PATCH(hide_dotfiles); } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("dir-listing.external-css"))) { PATCH(dirlist_css); + } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("dir-listing.hide"))) { + PATCH(dirlist_hide); } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.error-handler-404"))) { PATCH(error_handler); } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.indexfiles"))) { Index: src/base.h =================================================================== --- src/base.h (revision 107) +++ src/base.h (working copy) @@ -216,6 +216,7 @@ typedef struct { array *indexfiles; array *mimetypes; + array *dirlist_hide; /* virtual-servers */ buffer *document_root; Index: src/response.c =================================================================== --- src/response.c (revision 107) +++ src/response.c (working copy) @@ -643,6 +643,29 @@ ); } +static int http_list_directory_ishidden(array *hidden, const char *filename, size_t len) { + size_t i; + size_t ct_len; + data_string *ds; + + for (i = 0; i < hidden->used; i++) { + ds = (data_string*) hidden->data[i]; + + if (ds->value->used == 0) + continue; + + ct_len = ds->value->used - 1; + if (len < ct_len) + continue; + + if (strncmp(filename + len - ct_len, ds->value->ptr, ct_len) == 0) { + return 1; + } + } + + return 0; +} + static int http_list_directory(server *srv, connection *con, buffer *dir) { DIR *dp; buffer *out; @@ -656,6 +679,8 @@ char sizebuf[sizeof("999.9K")]; char datebuf[sizeof("2005-Jan-01 22:23:24")]; size_t k; + size_t ct_len; + data_string *ds; const char *content_type; #ifdef HAVE_XATTR char attrval[128]; @@ -706,6 +731,10 @@ i = strlen(dent->d_name); if (i > NAME_MAX) continue; + + if (http_list_directory_ishidden(con->conf.dirlist_hide, dent->d_name, i)) + continue; + memcpy(path_file, dent->d_name, i + 1); if (stat(path, &st) != 0) continue; @@ -780,8 +809,7 @@ #endif content_type = "application/octet-stream"; for (k = 0; k < con->conf.mimetypes->used; k++) { - data_string *ds = (data_string *)con->conf.mimetypes->data[k]; - size_t ct_len; + ds = (data_string *)con->conf.mimetypes->data[k]; if (ds->key->used == 0) continue; Index: src/server.c =================================================================== --- src/server.c (revision 107) +++ src/server.c (working copy) @@ -244,6 +244,7 @@ buffer_free(s->dirlist_css); array_free(s->indexfiles); array_free(s->mimetypes); + array_free(s->dirlist_hide); free(s); } Index: doc/configuration.txt =================================================================== --- doc/configuration.txt (revision 107) +++ doc/configuration.txt (working copy) @@ -191,6 +191,12 @@ dir-listing.external-css path to an external css stylesheet for the directory listing +dir-listing.hide + list of extensions to hide in directory listing. + e.g.: :: + + dir-listing.hide = ( "CVS", ".xyz" ) + server.follow-symlink allow to follow-symlinks