- add hyperlinks to the path components in the ``Index of /foo/bar/baz'' line, (except for the part representing current directory) if going there is allowed (i.e hyperlinks for ``/'', ``foo/'' and ``bar/'' but not for ``baz'') This also supports the case when the root ("/") is readable. - avoid adding a ``Go to parent directory'' line if target == current dir (i.e. if current dir == '/') Right now giving empty string for the dir in /magic/webls?dir= gives a directory of ``.''. One _might_ consider adding at the start of :/^dols if(strcmp(dir, "") ==0) dir = "/"; (i.e. before the ``cleanname(dir);'' statement) to normalize on "/" as the root. Axel. Reference: /n/sources/patch/applied/httpd-webls-clickable-path Date: Fri Jun 24 15:56:26 CES 2005 --- /sys/src/cmd/ip/httpd/webls.c Fri Jun 24 15:41:56 2005 +++ /sys/src/cmd/ip/httpd/webls.c Fri Jun 24 15:41:54 2005 @@ -197,11 +197,11 @@ dols(char *dir) { Dir *d; - char *f, *p; + char *f, *p,*nm; long i, n; int fd; - cleanname(dir); + cleanname(dir); // expands "" to "."; ``dir+1'' access below depends on that if (!allowed(dir)) { error("Permission denied", "

Cannot list directory %s: Access prohibited

", dir); return; @@ -220,7 +220,19 @@ hprint(hout, "\n"); hprint(hout, "Index of %s\n", dir); hprint(hout, "\n"); - hprint(hout, "

Index of %s

\n", dir); + hprint(hout, "

Index of "); + nm = dir; + while((p = strchr(nm, '/')) != nil){ + *p = '\0'; + f = (*dir == '\0') ? "/" : dir; + if (!(*dir == '\0' && *(dir+1) == '\0') && allowed(f)) + hprint(hout, "%s/", f, nm); + else + hprint(hout, "%s/", nm); + *p = '/'; + nm = p+1; + } + hprint(hout, "%s

\n", nm); n = dirreadall(fd, &d); close(fd); maxwidths(d, n); @@ -245,7 +257,7 @@ } f = smprint("%s/..", dir); cleanname(f); - if (allowed(f)) + if (strcmp(f, dir) != 0 && allowed(f)) hprint(hout, "\nGo to parent directory\n", f); else hprint(hout, "\nEnd of directory listing\n");