]> Sergey Matveev's repositories - godlighty.git/commitdiff
Proper escaping of dirlists with colons
authorSergey Matveev <stargrave@stargrave.org>
Sat, 12 Apr 2025 16:48:26 +0000 (19:48 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 12 Apr 2025 16:48:42 +0000 (19:48 +0300)
dirlist.go
dirlist.tmpl
godlighty.go

index 621fb889c508a90e7ec66dd273d4ed1ba0ed2128..bdf47ebdf306f393c19f74c2bb1767bec22d9756 100644 (file)
@@ -22,6 +22,7 @@ import (
        "os"
        "path"
        "sort"
+       "strings"
        "time"
 
        "github.com/dustin/go-humanize"
@@ -105,7 +106,7 @@ func dirList(
                Files  []DirListFile
        }{
                Root:   root,
-               Dir:    dir,
+               Dir:    strings.TrimRight(dir, "/"),
                Readme: readme,
                Files:  files,
        })
index 8fb266fad4c545397a4e50b802bcf4a3184478cc..b63ccd476a489b1b73d028388d465195e1282256 100644 (file)
@@ -13,7 +13,7 @@
 <tr><th>&nbsp;</th><th>Name</th><th>Mtime</th><th>Size</th><th>Type</th></tr>
 {{$Dir := .Dir}}{{$Root := .Root}}{{range .Files}}<tr>
   <td {{if .Symlink}}rowspan="2"{{end}}>{{.Idx}}</td>
-  <td><a href="{{$Root}}{{$Dir}}{{.Name}}{{if .IsDir}}/{{end -}}"><tt>
+  <td><a href="{{$Root}}{{$Dir}}/{{.Name}}{{if .IsDir}}/{{end -}}"><tt>
     {{- .Name}}{{if .IsDir}}/{{end}}</tt></a></td>
   <td><tt>{{.ModTime}}</tt></td>
   <td>{{.Size}}</td>
index ee2ff75011ed574e882f67cbb26ae1f4f4d8f64f..c81b102716b4e60ab025843566dbecd881df2f00 100644 (file)
@@ -1,6 +1,6 @@
 // Highly-customizable HTTP, HTTP/2, HTTPS server
 package godlighty
 
-const Version = "godlighty/0.7.0"
+const Version = "godlighty/0.8.0"
 
 var BindAddr string