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,7 +725,8 @@ make_content_buf(
tp = ngx_timeofday(); tp = ngx_timeofday();
/* "Parent dir" entry, always first */ /* "Parent dir" entry, always first if displayed */
if(r->uri.len > 1){
b->last = ngx_cpymem_ssz(b->last, b->last = ngx_cpymem_ssz(b->last,
"<tr>" "<tr>"
"<td><a href=\"../"); "<td><a href=\"../");
@ -732,6 +740,7 @@ make_content_buf(
"<td>-</td>" "<td>-</td>"
"<td>-</td>" "<td>-</td>"
"</tr>"); "</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++) {