Do not display the parent dir link at the root

If fancy indexing is used at the root of a webserver, it will still display
a "Parent Directory" link even when listing the webserver's root. This should
not happen as it outputs a useless link.
pull/28/head
Thomas P 2015-04-25 14:02:45 +02:00 committed by Adrian Perez de Castro
parent 3f3b408c17
commit 97987a45e4
1 changed files with 22 additions and 13 deletions

View File

@ -595,6 +595,13 @@ make_content_buf(
+ ngx_sizeof_ssz(t07_list2) + ngx_sizeof_ssz(t07_list2)
; ;
/*
* If we are a the root of the webserver (URI = "/" --> length of 1),
* do not display the "Parent Directory" link.
*/
if(r->uri.len == 1)
len -= ngx_sizeof_ssz(t_parentdir_entry);
entry = entries.elts; entry = entries.elts;
for (i = 0; i < entries.nelts; i++) { for (i = 0; i < entries.nelts; i++) {
/* /*
@ -718,20 +725,22 @@ make_content_buf(
tp = ngx_timeofday(); tp = ngx_timeofday();
/* "Parent dir" entry, always first */ /* "Parent dir" entry, always first if displayed */
b->last = ngx_cpymem_ssz(b->last, if(r->uri.len > 1){
"<tr>" b->last = ngx_cpymem_ssz(b->last,
"<td><a href=\"../"); "<tr>"
if (*sort_url_args) { "<td><a href=\"../");
b->last = ngx_cpymem(b->last, if (*sort_url_args) {
sort_url_args, b->last = ngx_cpymem(b->last,
ngx_sizeof_ssz("?C=N&amp;O=A")); sort_url_args,
ngx_sizeof_ssz("?C=N&amp;O=A"));
}
b->last = ngx_cpymem_ssz(b->last,
"\">Parent directory/</a></td>"
"<td>-</td>"
"<td>-</td>"
"</tr>");
} }
b->last = ngx_cpymem_ssz(b->last,
"\">Parent directory/</a></td>"
"<td>-</td>"
"<td>-</td>"
"</tr>");
/* Entries for directories and files */ /* Entries for directories and files */
for (i = 0; i < entries.nelts; i++) { for (i = 0; i < entries.nelts; i++) {