tagliatelle

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 5fb1f68c883d7d3f83dfdb3d10ff9d01dbd9325d
parent fcba3281bc2cde5a1d115ddbdc41cf85e535f40c
Author: breadcat <breadcat@users.noreply.github.com>
Date:   Sat,  7 Mar 2026 21:57:51 +0000

Allow deletion of tags containing # symbols

Diffstat:
Minclude-templates.go | 2++
Minclude-viewer.go | 12++++++++++--
Mtemplates/file.html | 4++--
3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/include-templates.go b/include-templates.go @@ -3,6 +3,7 @@ package main import ( "fmt" "html/template" + "net/url" "strings" ) @@ -11,6 +12,7 @@ func InitTemplates() (*template.Template, error) { return template.New("").Funcs(template.FuncMap{ "add": func(a, b int) int { return a + b }, "sub": func(a, b int) int { return a - b }, + "pathEscape": url.PathEscape, "hasPrefix": func(s, prefix string) bool { return strings.HasPrefix(s, prefix) }, diff --git a/include-viewer.go b/include-viewer.go @@ -168,8 +168,16 @@ func getLocalIP() (string, error) { func tagActionHandler(w http.ResponseWriter, r *http.Request, parts []string) { fileID := parts[2] - cat := parts[4] - val := parts[5] + cat, err := url.PathUnescape(parts[4]) + if err != nil { + http.Redirect(w, r, "/file/"+fileID, http.StatusSeeOther) + return + } + val, err := url.PathUnescape(parts[5]) + if err != nil { + http.Redirect(w, r, "/file/"+fileID, http.StatusSeeOther) + return + } action := parts[6] if action == "delete" && r.Method == http.MethodPost { diff --git a/templates/file.html b/templates/file.html @@ -13,8 +13,8 @@ <span class="file-tag-category">{{$k}}:</span><br> {{range $i, $v := $vs}} {{if $i}}<br> {{end}} - <form method="post" action="/file/{{$.Data.File.ID}}/tag/{{$k}}/{{$v}}/delete"><button class="text-button" type="submit">x</button></form> - <a href="/tag/{{$k}}/{{$v}}">{{$v}}</a> + <form method="post" action="/file/{{$.Data.File.ID}}/tag/{{pathEscape $k}}/{{pathEscape $v}}/delete"><button class="text-button" type="submit">x</button></form> + <a href="/tag/{{pathEscape $k}}/{{pathEscape $v}}">{{$v}}</a> {{end}} </li> {{else}}