From 1a88665961d63e2864c0cb3f69191bd702dc1a20 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Thu, 5 Dec 2024 00:24:40 -0800 Subject: [PATCH] Check writable for list --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index 31c3aa8..965a098 100644 --- a/main.go +++ b/main.go @@ -324,6 +324,11 @@ func (sl *ShortLinks) serveList(w http.ResponseWriter, r *http.Request) { return } + if !sl.isWritable(r.Host) { + sendError(w, http.StatusNotFound, "not found") + return + } + rows, err := sl.db.Query("SELECT short, long, domain, generated FROM links WHERE domain = $1 ORDER BY short ASC", sl.getDomain(r.Host)) if err != nil { sendError(w, http.StatusInternalServerError, "select links: %s", err)