1
0
Fork 0
forked from jriou/coller

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>
This commit is contained in:
Thibault Piron 2025-09-09 15:57:23 +02:00 committed by Julien Riou
parent 792eff78cc
commit af5baa999c

View file

@ -377,6 +377,12 @@ func (h *GetProtectedWebNoteHandler) ServeHTTP(w http.ResponseWriter, r *http.Re
return 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 { if password != "" && note.Encrypted {
note.Content, err = internal.Decrypt(note.Content, password) note.Content, err = internal.Decrypt(note.Content, password)
if err != nil { if err != nil {