[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/2818personal/stbuehler/mod-csrf
parent
6e668bfe5f
commit
07e57e24c2
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue