Browse Source

make encoding of dirlisting configurable (#136)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.3.x@399 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.3.15
Jan Kneschke 17 years ago
parent
commit
e2e1cc12b6
  1. 1
      src/base.h
  2. 7
      src/config.c
  3. 10
      src/response.c
  4. 1
      src/server.c

1
src/base.h

@ -223,6 +223,7 @@ typedef struct {
buffer *error_handler;
buffer *server_tag;
buffer *dirlist_css;
buffer *dirlist_encoding;
unsigned short dir_listing;
unsigned short hide_dotfiles;

7
src/config.c

@ -75,6 +75,8 @@ static int config_insert(server *srv) {
{ "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.encoding", NULL, T_CONFIG_STRING, 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 },
{ "server.virtual-root", "load mod_simple_vhost and use simple-vhost.server-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
@ -126,6 +128,7 @@ static int config_insert(server *srv) {
s->error_handler = buffer_init();
s->server_tag = buffer_init();
s->dirlist_css = buffer_init();
s->dirlist_encoding = buffer_init();
s->max_keep_alive_requests = 128;
s->max_keep_alive_idle = 30;
s->max_read_idle = 60;
@ -173,6 +176,7 @@ static int config_insert(server *srv) {
cv[38].destination = s->ssl_ca_file;
cv[39].destination = &(s->hide_dotfiles);
cv[40].destination = s->dirlist_css;
cv[41].destination = s->dirlist_encoding;
srv->config_storage[i] = s;
@ -195,6 +199,7 @@ int config_setup_connection(server *srv, connection *con) {
PATCH(document_root);
PATCH(dir_listing);
PATCH(dirlist_css);
PATCH(dirlist_encoding);
PATCH(hide_dotfiles);
PATCH(indexfiles);
PATCH(max_keep_alive_requests);
@ -245,6 +250,8 @@ int config_patch_connection(server *srv, connection *con, const char *stage, siz
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.encoding"))) {
PATCH(dirlist_encoding);
} 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"))) {

10
src/response.c

@ -742,7 +742,15 @@ static int http_list_directory(server *srv, connection *con, buffer *dir) {
if (files.used) http_dirls_sort(files.ent, files.used);
out = chunkqueue_get_append_buffer(con->write_queue);
BUFFER_COPY_STRING_CONST(out, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
if (buffer_is_empty(con->conf.dirlist_encoding)) {
BUFFER_COPY_STRING_CONST(out, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
} else {
BUFFER_COPY_STRING_CONST(out, "<?xml version=\"1.0\" encoding=\"");
buffer_append_string_buffer(out, con->conf.dirlist_encoding);
BUFFER_APPEND_STRING_CONST(out, "\"?>\n");
}
http_list_directory_header(out, con);
/* directories */

1
src/server.c

@ -242,6 +242,7 @@ static void server_free(server *srv) {
buffer_free(s->ssl_ca_file);
buffer_free(s->error_handler);
buffer_free(s->dirlist_css);
buffer_free(s->dirlist_encoding);
array_free(s->indexfiles);
array_free(s->mimetypes);

Loading…
Cancel
Save