version 1.1.1.2, 2014/06/15 20:20:06
|
version 1.1.1.3, 2016/11/02 10:35:00
|
Line 1
|
Line 1
|
|
#include "first.h" |
|
|
#include "base.h" |
#include "base.h" |
#include "log.h" |
#include "log.h" |
#include "buffer.h" |
#include "buffer.h" |
Line 14
|
Line 16
|
#include <dirent.h> |
#include <dirent.h> |
#include <assert.h> |
#include <assert.h> |
#include <errno.h> |
#include <errno.h> |
|
#include <fcntl.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <unistd.h> |
#include <unistd.h> |
#include <time.h> |
#include <time.h> |
Line 22
|
Line 25
|
* this is a dirlisting for a lighttpd plugin |
* this is a dirlisting for a lighttpd plugin |
*/ |
*/ |
|
|
|
|
#ifdef HAVE_SYS_SYSLIMITS_H |
|
#include <sys/syslimits.h> |
|
#endif |
|
|
|
#ifdef HAVE_ATTR_ATTRIBUTES_H |
#ifdef HAVE_ATTR_ATTRIBUTES_H |
#include <attr/attributes.h> |
#include <attr/attributes.h> |
#endif |
#endif |
|
|
#include "version.h" | #ifdef HAVE_SYS_EXTATTR_H |
| #include <sys/extattr.h> |
| #endif |
|
|
/* plugin config for all request/connections */ |
/* plugin config for all request/connections */ |
|
|
Line 120 static int excludes_buffer_append(excludes_buffer *exb
|
Line 120 static int excludes_buffer_append(excludes_buffer *exb
|
} |
} |
|
|
exb->ptr[exb->used]->string = buffer_init(); |
exb->ptr[exb->used]->string = buffer_init(); |
buffer_copy_string_buffer(exb->ptr[exb->used]->string, string); | buffer_copy_buffer(exb->ptr[exb->used]->string, string); |
|
|
exb->used++; |
exb->used++; |
|
|
Line 194 FREE_FUNC(mod_dirlisting_free) {
|
Line 194 FREE_FUNC(mod_dirlisting_free) {
|
return HANDLER_GO_ON; |
return HANDLER_GO_ON; |
} |
} |
|
|
static int parse_config_entry(server *srv, plugin_config *s, array *ca, const char *option) { |
|
data_unset *du; |
|
|
|
if (NULL != (du = array_get_element(ca, option))) { |
|
data_array *da; |
|
size_t j; |
|
|
|
if (du->type != TYPE_ARRAY) { |
|
log_error_write(srv, __FILE__, __LINE__, "sss", |
|
"unexpected type for key: ", option, "array of strings"); |
|
|
|
return HANDLER_ERROR; |
|
} |
|
|
|
da = (data_array *)du; |
|
|
|
for (j = 0; j < da->value->used; j++) { |
|
if (da->value->data[j]->type != TYPE_STRING) { |
|
log_error_write(srv, __FILE__, __LINE__, "sssbs", |
|
"unexpected type for key: ", option, "[", |
|
da->value->data[j]->key, "](string)"); |
|
|
|
return HANDLER_ERROR; |
|
} |
|
|
|
if (0 != excludes_buffer_append(s->excludes, |
|
((data_string *)(da->value->data[j]))->value)) { |
|
#ifdef HAVE_PCRE_H |
|
log_error_write(srv, __FILE__, __LINE__, "sb", |
|
"pcre-compile failed for", ((data_string *)(da->value->data[j]))->value); |
|
#else |
|
log_error_write(srv, __FILE__, __LINE__, "s", |
|
"pcre support is missing, please install libpcre and the headers"); |
|
#endif |
|
} |
|
} |
|
} |
|
|
|
return 0; |
|
} |
|
|
|
/* handle plugin config and check values */ |
/* handle plugin config and check values */ |
|
|
#define CONFIG_EXCLUDE "dir-listing.exclude" |
#define CONFIG_EXCLUDE "dir-listing.exclude" |
Line 281 SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) {
|
Line 240 SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) {
|
p->config_storage = calloc(1, srv->config_context->used * sizeof(plugin_config *)); |
p->config_storage = calloc(1, srv->config_context->used * sizeof(plugin_config *)); |
|
|
for (i = 0; i < srv->config_context->used; i++) { |
for (i = 0; i < srv->config_context->used; i++) { |
|
data_config const* config = (data_config const*)srv->config_context->data[i]; |
plugin_config *s; |
plugin_config *s; |
array *ca; | data_unset *du_excludes; |
|
|
s = calloc(1, sizeof(plugin_config)); |
s = calloc(1, sizeof(plugin_config)); |
s->excludes = excludes_buffer_init(); |
s->excludes = excludes_buffer_init(); |
s->dir_listing = 0; |
s->dir_listing = 0; |
s->external_css = buffer_init(); |
s->external_css = buffer_init(); |
s->hide_dot_files = 0; | s->hide_dot_files = 1; |
s->show_readme = 0; |
s->show_readme = 0; |
s->hide_readme_file = 0; |
s->hide_readme_file = 0; |
s->show_header = 0; |
s->show_header = 0; |
Line 316 SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) {
|
Line 276 SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) {
|
cv[13].destination = &(s->auto_layout); |
cv[13].destination = &(s->auto_layout); |
|
|
p->config_storage[i] = s; |
p->config_storage[i] = s; |
ca = ((data_config *)srv->config_context->data[i])->value; |
|
|
|
if (0 != config_insert_values_global(srv, ca, cv)) { | if (0 != config_insert_values_global(srv, config->value, cv, i == 0 ? T_CONFIG_SCOPE_SERVER : T_CONFIG_SCOPE_CONNECTION)) { |
return HANDLER_ERROR; |
return HANDLER_ERROR; |
} |
} |
|
|
parse_config_entry(srv, s, ca, CONFIG_EXCLUDE); | if (NULL != (du_excludes = array_get_element(config->value, CONFIG_EXCLUDE))) { |
| array *excludes_list; |
| size_t j; |
| |
| if (du_excludes->type != TYPE_ARRAY) { |
| log_error_write(srv, __FILE__, __LINE__, "sss", |
| "unexpected type for key: ", CONFIG_EXCLUDE, "array of strings"); |
| return HANDLER_ERROR; |
| } |
| |
| excludes_list = ((data_array*)du_excludes)->value; |
| |
| #ifndef HAVE_PCRE_H |
| if (excludes_list->used > 0) { |
| log_error_write(srv, __FILE__, __LINE__, "sss", |
| "pcre support is missing for: ", CONFIG_EXCLUDE, ", please install libpcre and the headers"); |
| return HANDLER_ERROR; |
| } |
| #else |
| for (j = 0; j < excludes_list->used; j++) { |
| data_unset *du_exclude = excludes_list->data[j]; |
| |
| if (du_exclude->type != TYPE_STRING) { |
| log_error_write(srv, __FILE__, __LINE__, "sssbs", |
| "unexpected type for key: ", CONFIG_EXCLUDE, "[", |
| du_exclude->key, "](string)"); |
| return HANDLER_ERROR; |
| } |
| |
| if (0 != excludes_buffer_append(s->excludes, ((data_string*)(du_exclude))->value)) { |
| log_error_write(srv, __FILE__, __LINE__, "sb", |
| "pcre-compile failed for", ((data_string*)(du_exclude))->value); |
| return HANDLER_ERROR; |
| } |
| } |
| #endif |
| } |
} |
} |
|
|
return HANDLER_GO_ON; |
return HANDLER_GO_ON; |
Line 441 static void http_dirls_sort(dirls_entry_t **ent, int n
|
Line 436 static void http_dirls_sort(dirls_entry_t **ent, int n
|
/* buffer must be able to hold "999.9K" |
/* buffer must be able to hold "999.9K" |
* conversion is simple but not perfect |
* conversion is simple but not perfect |
*/ |
*/ |
static int http_list_directory_sizefmt(char *buf, off_t size) { | static int http_list_directory_sizefmt(char *buf, size_t bufsz, off_t size) { |
const char unit[] = "KMGTPE"; /* Kilo, Mega, Tera, Peta, Exa */ | const char unit[] = " KMGTPE"; /* Kilo, Mega, Giga, Tera, Peta, Exa */ |
const char *u = unit - 1; /* u will always increment at least once */ | const char *u = unit; /* u will always increment at least once */ |
int remain; |
int remain; |
char *out = buf; | size_t buflen; |
|
|
if (size < 100) |
if (size < 100) |
size += 99; |
size += 99; |
Line 469 static int http_list_directory_sizefmt(char *buf, off_
|
Line 464 static int http_list_directory_sizefmt(char *buf, off_
|
u++; |
u++; |
} |
} |
|
|
out += LI_ltostr(out, size); | li_itostrn(buf, bufsz, size); |
out[0] = '.'; | buflen = strlen(buf); |
out[1] = remain + '0'; | if (buflen + 3 >= bufsz) return buflen; |
out[2] = *u; | buf[buflen+0] = '.'; |
out[3] = '\0'; | buf[buflen+1] = remain + '0'; |
| buf[buflen+2] = *u; |
| buf[buflen+3] = '\0'; |
|
|
return (out + 3 - buf); | return buflen + 3; |
} |
} |
|
|
|
/* don't want to block when open()ing a fifo */ |
|
#if defined(O_NONBLOCK) |
|
# define FIFO_NONBLOCK O_NONBLOCK |
|
#else |
|
# define FIFO_NONBLOCK 0 |
|
#endif |
|
|
|
static void http_list_directory_include_file(buffer *out, buffer *path, const char *classname, int encode) { |
|
int fd = open(path->ptr, O_RDONLY | FIFO_NONBLOCK); |
|
ssize_t rd; |
|
char buf[8192]; |
|
|
|
if (-1 == fd) return; |
|
|
|
if (encode) { |
|
buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"")); |
|
buffer_append_string(out, classname); |
|
buffer_append_string_len(out, CONST_STR_LEN("\">")); |
|
} |
|
|
|
while ((rd = read(fd, buf, sizeof(buf))) > 0) { |
|
if (encode) { |
|
buffer_append_string_encoded(out, buf, (size_t)rd, ENCODING_MINIMAL_XML); |
|
} else { |
|
buffer_append_string_len(out, buf, (size_t)rd); |
|
} |
|
} |
|
close(fd); |
|
|
|
if (encode) { |
|
buffer_append_string_len(out, CONST_STR_LEN("</pre>")); |
|
} |
|
} |
|
|
static void http_list_directory_header(server *srv, connection *con, plugin_data *p, buffer *out) { |
static void http_list_directory_header(server *srv, connection *con, plugin_data *p, buffer *out) { |
UNUSED(srv); |
UNUSED(srv); |
|
|
Line 491 static void http_list_directory_header(server *srv, co
|
Line 522 static void http_list_directory_header(server *srv, co
|
buffer_append_string_encoded(out, CONST_BUF_LEN(con->uri.path), ENCODING_MINIMAL_XML); |
buffer_append_string_encoded(out, CONST_BUF_LEN(con->uri.path), ENCODING_MINIMAL_XML); |
buffer_append_string_len(out, CONST_STR_LEN("</title>\n")); |
buffer_append_string_len(out, CONST_STR_LEN("</title>\n")); |
|
|
if (p->conf.external_css->used > 1) { | if (!buffer_string_is_empty(p->conf.external_css)) { |
buffer_append_string_len(out, CONST_STR_LEN("<link rel=\"stylesheet\" type=\"text/css\" href=\"")); |
buffer_append_string_len(out, CONST_STR_LEN("<link rel=\"stylesheet\" type=\"text/css\" href=\"")); |
buffer_append_string_buffer(out, p->conf.external_css); |
buffer_append_string_buffer(out, p->conf.external_css); |
buffer_append_string_len(out, CONST_STR_LEN("\" />\n")); |
buffer_append_string_len(out, CONST_STR_LEN("\" />\n")); |
Line 536 static void http_list_directory_header(server *srv, co
|
Line 567 static void http_list_directory_header(server *srv, co
|
|
|
/* HEADER.txt */ |
/* HEADER.txt */ |
if (p->conf.show_header) { |
if (p->conf.show_header) { |
stream s; |
|
/* if we have a HEADER file, display it in <pre class="header"></pre> */ |
/* if we have a HEADER file, display it in <pre class="header"></pre> */ |
|
|
buffer_copy_string_buffer(p->tmp_buf, con->physical.path); | buffer_copy_buffer(p->tmp_buf, con->physical.path); |
BUFFER_APPEND_SLASH(p->tmp_buf); | buffer_append_slash(p->tmp_buf); |
buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("HEADER.txt")); |
buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("HEADER.txt")); |
|
|
if (-1 != stream_open(&s, p->tmp_buf)) { | http_list_directory_include_file(out, p->tmp_buf, "header", p->conf.encode_header); |
if (p->conf.encode_header) { | |
buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"header\">")); | |
buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML); | |
buffer_append_string_len(out, CONST_STR_LEN("</pre>")); | |
} else { | |
buffer_append_string_len(out, s.start, s.size); | |
} | |
} | |
stream_close(&s); | |
} |
} |
|
|
buffer_append_string_len(out, CONST_STR_LEN("<h2>Index of ")); |
buffer_append_string_len(out, CONST_STR_LEN("<h2>Index of ")); |
Line 570 static void http_list_directory_header(server *srv, co
|
Line 591 static void http_list_directory_header(server *srv, co
|
"</tr>" |
"</tr>" |
"</thead>\n" |
"</thead>\n" |
"<tbody>\n" |
"<tbody>\n" |
"<tr>" | "<tr class=\"d\">" |
"<td class=\"n\"><a href=\"../\">Parent Directory</a>/</td>" |
"<td class=\"n\"><a href=\"../\">Parent Directory</a>/</td>" |
"<td class=\"m\"> </td>" |
"<td class=\"m\"> </td>" |
"<td class=\"s\">- </td>" |
"<td class=\"s\">- </td>" |
Line 589 static void http_list_directory_footer(server *srv, co
|
Line 610 static void http_list_directory_footer(server *srv, co
|
)); |
)); |
|
|
if (p->conf.show_readme) { |
if (p->conf.show_readme) { |
stream s; |
|
/* if we have a README file, display it in <pre class="readme"></pre> */ |
/* if we have a README file, display it in <pre class="readme"></pre> */ |
|
|
buffer_copy_string_buffer(p->tmp_buf, con->physical.path); | buffer_copy_buffer(p->tmp_buf, con->physical.path); |
BUFFER_APPEND_SLASH(p->tmp_buf); | buffer_append_slash(p->tmp_buf); |
buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("README.txt")); |
buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("README.txt")); |
|
|
if (-1 != stream_open(&s, p->tmp_buf)) { | http_list_directory_include_file(out, p->tmp_buf, "readme", p->conf.encode_readme); |
if (p->conf.encode_readme) { | |
buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"readme\">")); | |
buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML); | |
buffer_append_string_len(out, CONST_STR_LEN("</pre>")); | |
} else { | |
buffer_append_string_len(out, s.start, s.size); | |
} | |
} | |
stream_close(&s); | |
} |
} |
|
|
if(p->conf.auto_layout) { |
if(p->conf.auto_layout) { |
Line 613 static void http_list_directory_footer(server *srv, co
|
Line 624 static void http_list_directory_footer(server *srv, co
|
"<div class=\"foot\">" |
"<div class=\"foot\">" |
)); |
)); |
|
|
if (p->conf.set_footer->used > 1) { | if (!buffer_string_is_empty(p->conf.set_footer)) { |
buffer_append_string_buffer(out, p->conf.set_footer); |
buffer_append_string_buffer(out, p->conf.set_footer); |
} else if (buffer_is_empty(con->conf.server_tag)) { |
|
buffer_append_string_len(out, CONST_STR_LEN(PACKAGE_DESC)); |
|
} else { |
} else { |
buffer_append_string_buffer(out, con->conf.server_tag); |
buffer_append_string_buffer(out, con->conf.server_tag); |
} |
} |
Line 644 static int http_list_directory(server *srv, connection
|
Line 653 static int http_list_directory(server *srv, connection
|
size_t k; |
size_t k; |
const char *content_type; |
const char *content_type; |
long name_max; |
long name_max; |
#ifdef HAVE_XATTR | #if defined(HAVE_XATTR) || defined(HAVE_EXTATTR) |
char attrval[128]; |
char attrval[128]; |
int attrlen; |
int attrlen; |
#endif |
#endif |
Line 652 static int http_list_directory(server *srv, connection
|
Line 661 static int http_list_directory(server *srv, connection
|
struct tm tm; |
struct tm tm; |
#endif |
#endif |
|
|
if (dir->used == 0) return -1; | if (buffer_string_is_empty(dir)) return -1; |
|
|
i = dir->used - 1; | i = buffer_string_length(dir); |
|
|
#ifdef HAVE_PATHCONF |
#ifdef HAVE_PATHCONF |
if (0 >= (name_max = pathconf(dir->ptr, _PC_NAME_MAX))) { |
if (0 >= (name_max = pathconf(dir->ptr, _PC_NAME_MAX))) { |
Line 671 static int http_list_directory(server *srv, connection
|
Line 680 static int http_list_directory(server *srv, connection
|
name_max = NAME_MAX; |
name_max = NAME_MAX; |
#endif |
#endif |
|
|
path = malloc(dir->used + name_max); | path = malloc(i + name_max + 1); |
force_assert(path); | force_assert(NULL != path); |
strcpy(path, dir->ptr); | memcpy(path, dir->ptr, i+1); |
path_file = path + i; |
path_file = path + i; |
|
|
if (NULL == (dp = opendir(path))) { |
if (NULL == (dp = opendir(path))) { |
Line 783 static int http_list_directory(server *srv, connection
|
Line 792 static int http_list_directory(server *srv, connection
|
|
|
if (files.used) http_dirls_sort(files.ent, files.used); |
if (files.used) http_dirls_sort(files.ent, files.used); |
|
|
out = chunkqueue_get_append_buffer(con->write_queue); | out = buffer_init(); |
buffer_copy_string_len(out, CONST_STR_LEN("<?xml version=\"1.0\" encoding=\"")); |
buffer_copy_string_len(out, CONST_STR_LEN("<?xml version=\"1.0\" encoding=\"")); |
if (buffer_is_empty(p->conf.encoding)) { | if (buffer_string_is_empty(p->conf.encoding)) { |
buffer_append_string_len(out, CONST_STR_LEN("iso-8859-1")); |
buffer_append_string_len(out, CONST_STR_LEN("iso-8859-1")); |
} else { |
} else { |
buffer_append_string_buffer(out, p->conf.encoding); |
buffer_append_string_buffer(out, p->conf.encoding); |
Line 804 static int http_list_directory(server *srv, connection
|
Line 813 static int http_list_directory(server *srv, connection
|
strftime(datebuf, sizeof(datebuf), "%Y-%b-%d %H:%M:%S", localtime(&(tmp->mtime))); |
strftime(datebuf, sizeof(datebuf), "%Y-%b-%d %H:%M:%S", localtime(&(tmp->mtime))); |
#endif |
#endif |
|
|
buffer_append_string_len(out, CONST_STR_LEN("<tr><td class=\"n\"><a href=\"")); | buffer_append_string_len(out, CONST_STR_LEN("<tr class=\"d\"><td class=\"n\"><a href=\"")); |
buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_REL_URI_PART); |
buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_REL_URI_PART); |
buffer_append_string_len(out, CONST_STR_LEN("/\">")); |
buffer_append_string_len(out, CONST_STR_LEN("/\">")); |
buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_MINIMAL_XML); |
buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_MINIMAL_XML); |
Line 820 static int http_list_directory(server *srv, connection
|
Line 829 static int http_list_directory(server *srv, connection
|
tmp = files.ent[i]; |
tmp = files.ent[i]; |
|
|
content_type = NULL; |
content_type = NULL; |
#ifdef HAVE_XATTR | #if defined(HAVE_XATTR) |
| |
if (con->conf.use_xattr) { |
if (con->conf.use_xattr) { |
memcpy(path_file, DIRLIST_ENT_NAME(tmp), tmp->namelen + 1); |
memcpy(path_file, DIRLIST_ENT_NAME(tmp), tmp->namelen + 1); |
attrlen = sizeof(attrval) - 1; |
attrlen = sizeof(attrval) - 1; |
if (attr_get(path, "Content-Type", attrval, &attrlen, 0) == 0) { | if (attr_get(path, srv->srvconf.xattr_name->ptr, attrval, &attrlen, 0) == 0) { |
attrval[attrlen] = '\0'; |
attrval[attrlen] = '\0'; |
content_type = attrval; |
content_type = attrval; |
} |
} |
} |
} |
|
#elif defined(HAVE_EXTATTR) |
|
if (con->conf.use_xattr) { |
|
memcpy(path_file, DIRLIST_ENT_NAME(tmp), tmp->namelen + 1); |
|
if(-1 != (attrlen = extattr_get_file(path, EXTATTR_NAMESPACE_USER, srv->srvconf.xattr_name->ptr, attrval, sizeof(attrval)-1))) { |
|
attrval[attrlen] = '\0'; |
|
content_type = attrval; |
|
} |
|
} |
#endif |
#endif |
|
|
if (content_type == NULL) { |
if (content_type == NULL) { |
Line 838 static int http_list_directory(server *srv, connection
|
Line 854 static int http_list_directory(server *srv, connection
|
data_string *ds = (data_string *)con->conf.mimetypes->data[k]; |
data_string *ds = (data_string *)con->conf.mimetypes->data[k]; |
size_t ct_len; |
size_t ct_len; |
|
|
if (ds->key->used == 0) | if (buffer_is_empty(ds->key)) |
continue; |
continue; |
|
|
ct_len = ds->key->used - 1; | ct_len = buffer_string_length(ds->key); |
if (tmp->namelen < ct_len) |
if (tmp->namelen < ct_len) |
continue; |
continue; |
|
|
Line 858 static int http_list_directory(server *srv, connection
|
Line 874 static int http_list_directory(server *srv, connection
|
#else |
#else |
strftime(datebuf, sizeof(datebuf), "%Y-%b-%d %H:%M:%S", localtime(&(tmp->mtime))); |
strftime(datebuf, sizeof(datebuf), "%Y-%b-%d %H:%M:%S", localtime(&(tmp->mtime))); |
#endif |
#endif |
http_list_directory_sizefmt(sizebuf, tmp->size); | http_list_directory_sizefmt(sizebuf, sizeof(sizebuf), tmp->size); |
|
|
buffer_append_string_len(out, CONST_STR_LEN("<tr><td class=\"n\"><a href=\"")); |
buffer_append_string_len(out, CONST_STR_LEN("<tr><td class=\"n\"><a href=\"")); |
buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_REL_URI_PART); |
buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_REL_URI_PART); |
Line 882 static int http_list_directory(server *srv, connection
|
Line 898 static int http_list_directory(server *srv, connection
|
http_list_directory_footer(srv, con, p, out); |
http_list_directory_footer(srv, con, p, out); |
|
|
/* Insert possible charset to Content-Type */ |
/* Insert possible charset to Content-Type */ |
if (buffer_is_empty(p->conf.encoding)) { | if (buffer_string_is_empty(p->conf.encoding)) { |
response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html")); |
response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html")); |
} else { |
} else { |
buffer_copy_string_len(p->content_charset, CONST_STR_LEN("text/html; charset=")); |
buffer_copy_string_len(p->content_charset, CONST_STR_LEN("text/html; charset=")); |
Line 891 static int http_list_directory(server *srv, connection
|
Line 907 static int http_list_directory(server *srv, connection
|
} |
} |
|
|
con->file_finished = 1; |
con->file_finished = 1; |
|
chunkqueue_append_buffer(con->write_queue, out); |
|
buffer_free(out); |
|
|
return 0; |
return 0; |
} |
} |
Line 915 URIHANDLER_FUNC(mod_dirlisting_subrequest) {
|
Line 933 URIHANDLER_FUNC(mod_dirlisting_subrequest) {
|
|
|
if (con->mode != DIRECT) return HANDLER_GO_ON; |
if (con->mode != DIRECT) return HANDLER_GO_ON; |
|
|
if (con->physical.path->used == 0) return HANDLER_GO_ON; | if (buffer_is_empty(con->physical.path)) return HANDLER_GO_ON; |
if (con->uri.path->used == 0) return HANDLER_GO_ON; | if (buffer_is_empty(con->uri.path)) return HANDLER_GO_ON; |
if (con->uri.path->ptr[con->uri.path->used - 2] != '/') return HANDLER_GO_ON; | if (con->uri.path->ptr[buffer_string_length(con->uri.path) - 1] != '/') return HANDLER_GO_ON; |
|
|
mod_dirlisting_patch_connection(srv, con, p); |
mod_dirlisting_patch_connection(srv, con, p); |
|
|