diff --git a/gossa.go b/gossa.go index 38a0a43..293eab5 100644 --- a/gossa.go +++ b/gossa.go @@ -25,7 +25,7 @@ import ( type rowTemplate struct { Name string - Href template.HTML + Href template.URL Size string Ext string } @@ -122,11 +122,13 @@ func replyList(w http.ResponseWriter, r *http.Request, fullPath string, path str } if el.IsDir() { - p.RowsFolders = append(p.RowsFolders, rowTemplate{name + "/", template.HTML(href), "", "folder"}) + row := rowTemplate{name + "/", template.URL(href), "", "folder"} + p.RowsFolders = append(p.RowsFolders, row) } else { sl := strings.Split(name, ".") ext := strings.ToLower(sl[len(sl)-1]) - p.RowsFiles = append(p.RowsFiles, rowTemplate{name, template.HTML(href), humanize(el.Size()), ext}) + row := rowTemplate{name, template.URL(href), humanize(el.Size()), ext} + p.RowsFiles = append(p.RowsFiles, row) } } diff --git a/gossa_test.go b/gossa_test.go index 9521677..d388993 100644 --- a/gossa_test.go +++ b/gossa_test.go @@ -204,6 +204,17 @@ func doTestRegular(t *testing.T, url string, testExtra bool) { t.Fatal("post file incorrect path didnt errored") } + // ~~~~~~~~~~~~~~~~~ + fmt.Println("\r\n~~~~~~~~~~ test post file") + path = "2024-01-02-10:36:58.png" + payload = "123123123123123123123123" + body0 = postDummyFile(t, url, path, payload) + body1 = get(t, url+path) + body2 = fetchAndTestDefault(t, url) + if body0 != `ok` || body1 != payload || !strings.Contains(body2, `href="2024-01-02-10:36:58.png"`) { + t.Fatal("post file errored") + } + // ~~~~~~~~~~~~~~~~~ fmt.Println("\r\n~~~~~~~~~~ test mv rpc") body0 = postJSON(t, url+"rpc", `{"call":"mv","args":["/AAA", "/hols/AAA"]}`)