From b0f27c6f741b34cfcc8b8bdebd34d979eb79ebd3 Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Sat, 7 May 2022 13:51:28 -0400 Subject: [PATCH] fs: Prevent invalid directory links A file with a name like "gemini:example" would previously result in the following invalid link: => gemini:example gemini:example Fix by prepending a "./" before each filename, so that the resulting link looks like: => ./gemini:example gemini:example --- fs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs.go b/fs.go index 7a73150..e24b8e5 100644 --- a/fs.go +++ b/fs.go @@ -169,7 +169,7 @@ func dirList(w ResponseWriter, f fs.File) { } link := LineLink{ Name: name, - URL: (&url.URL{Path: name}).EscapedPath(), + URL: "./" + url.PathEscape(name), } fmt.Fprintln(w, link.String()) }