summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-07-28 00:07:01 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2017-07-28 00:11:28 -0400
commit07e57e24c2201ef80ded0f9625b04213298a736d (patch)
tree4e43d65d70780c325cf2d98dceea155110eb146d
parent6e668bfe5fb5eebe97209fdc2e6f7a6059a0ee27 (diff)
downloadlighttpd1.4-07e57e24c2201ef80ded0f9625b04213298a736d.tar.gz
lighttpd1.4-07e57e24c2201ef80ded0f9625b04213298a736d.zip
[mod_dirlisting] treat README and HEADER as paths (fixes #2818)
Treat README and HEADER as filepaths. If absolute path, take as-is. If relative path, then take relative to directory physical path. This extends dir-listing.show-header and dir-listing.show-readme feature to take a filename, which was introduced in lighttpd 1.4.43 x-ref: "Custom HEADER and README filepaths in mod_dirlisting are treated as relative paths instead of absolute paths when file name starts with '/'" https://redmine.lighttpd.net/issue/2818
-rw-r--r--src/mod_dirlisting.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/mod_dirlisting.c b/src/mod_dirlisting.c
index 2ea0d94c..382fa09a 100644
--- a/src/mod_dirlisting.c
+++ b/src/mod_dirlisting.c
@@ -786,11 +786,15 @@ static void http_list_directory_header(server *srv, connection *con, plugin_data
if (!buffer_string_is_empty(p->conf.show_header)) {
/* if we have a HEADER file, display it in <pre class="header"></pre> */
- buffer_copy_buffer(p->tmp_buf, con->physical.path);
- buffer_append_slash(p->tmp_buf);
- buffer_append_string_buffer(p->tmp_buf, p->conf.show_header);
+ buffer *hb = p->conf.show_header;
+ if (hb->ptr[0] != '/') {
+ buffer_copy_buffer(p->tmp_buf, con->physical.path);
+ buffer_append_slash(p->tmp_buf);
+ buffer_append_string_buffer(p->tmp_buf, p->conf.show_header);
+ hb = p->tmp_buf;
+ }
- http_list_directory_include_file(out, p->tmp_buf, "header", p->conf.encode_header);
+ http_list_directory_include_file(out, hb, "header", p->conf.encode_header);
}
buffer_append_string_len(out, CONST_STR_LEN("<h2>Index of "));
@@ -833,11 +837,15 @@ static void http_list_directory_footer(server *srv, connection *con, plugin_data
if (!buffer_string_is_empty(p->conf.show_readme)) {
/* if we have a README file, display it in <pre class="readme"></pre> */
- buffer_copy_buffer(p->tmp_buf, con->physical.path);
- buffer_append_slash(p->tmp_buf);
- buffer_append_string_buffer(p->tmp_buf, p->conf.show_readme);
+ buffer *rb = p->conf.show_readme;
+ if (rb->ptr[0] != '/') {
+ buffer_copy_buffer(p->tmp_buf, con->physical.path);
+ buffer_append_slash(p->tmp_buf);
+ buffer_append_string_buffer(p->tmp_buf, p->conf.show_readme);
+ rb = p->tmp_buf;
+ }
- http_list_directory_include_file(out, p->tmp_buf, "readme", p->conf.encode_readme);
+ http_list_directory_include_file(out, rb, "readme", p->conf.encode_readme);
}
if(p->conf.auto_layout) {