1
0
Fork 0
forked from jriou/coller

Compare commits

..

2 commits

Author SHA1 Message Date
401397241b
fix: Upload text files other than plain text
Fixes #23

Signed-off-by: Julien Riou <julien@riou.xyz>
2025-09-10 07:02:48 +02:00
af5baa999c fix: display error page if note not found (#24)
Fix panic when trying to access a non existing note with the "pretty" url (.html)

Reviewed-on: jriou/coller#24
Reviewed-by: Julien Riou <jriou@monitoring@riou.xyz>
Co-authored-by: Thibault Piron <thibault.piron.ext@ovhcloud.com>
Co-committed-by: Thibault Piron <thibault.piron.ext@ovhcloud.com>
2025-09-09 15:57:23 +02:00

View file

@ -246,7 +246,7 @@ func (h *CreateNoteWithFormHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
}
h.logger.Debug("checking file content type")
if handler.Header.Get("Content-Type") != "text/plain" {
if !strings.HasPrefix(handler.Header.Get("Content-Type"), "text/") {
h.PageData.Err = fmt.Errorf("text file expected (got %s)", handler.Header.Get("Content-Type"))
h.Templates.ExecuteTemplate(w, templateName, h.PageData)
return
@ -377,6 +377,12 @@ func (h *GetProtectedWebNoteHandler) ServeHTTP(w http.ResponseWriter, r *http.Re
return
}
if note == nil {
h.PageData.Err = fmt.Errorf("Note doesn't exist or has been deleted")
h.Templates.ExecuteTemplate(w, templateName, h.PageData)
return
}
if password != "" && note.Encrypted {
note.Content, err = internal.Decrypt(note.Content, password)
if err != nil {