From ee4a911412332b9a4b9205940fafe8604793866c Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 12 Apr 2025 19:48:26 +0300 Subject: [PATCH] Proper escaping of dirlists with colons --- dirlist.go | 3 ++- dirlist.tmpl | 2 +- godlighty.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dirlist.go b/dirlist.go index 621fb88..bdf47eb 100644 --- a/dirlist.go +++ b/dirlist.go @@ -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, }) diff --git a/dirlist.tmpl b/dirlist.tmpl index 8fb266f..b63ccd4 100644 --- a/dirlist.tmpl +++ b/dirlist.tmpl @@ -13,7 +13,7 @@  NameMtimeSizeType {{$Dir := .Dir}}{{$Root := .Root}}{{range .Files}} {{.Idx}} - + {{- .Name}}{{if .IsDir}}/{{end}} {{.ModTime}} {{.Size}} diff --git a/godlighty.go b/godlighty.go index ee2ff75..c81b102 100644 --- a/godlighty.go +++ b/godlighty.go @@ -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 -- 2.48.1