From e95871ee7008ed7b1f147ef11378b5ce1a917310 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Tue, 29 Oct 2024 16:43:42 +0100 Subject: [PATCH] Fix bug that allowed empty banner images --- cmd/frontend/articles.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/frontend/articles.go b/cmd/frontend/articles.go index 9b73385..806c7ae 100644 --- a/cmd/frontend/articles.go +++ b/cmd/frontend/articles.go @@ -80,7 +80,7 @@ func SubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc { article := &b.Article{ Title: r.PostFormValue("article-title"), - BannerLink: c.Domain + "/image/serve/" + r.PostFormValue("article-banner-url"), + BannerLink: r.PostFormValue("article-banner-url"), Summary: r.PostFormValue("article-summary"), Published: false, Rejected: false, @@ -93,10 +93,13 @@ func SubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc { http.Error(w, "Bitte den Titel eingeben.", http.StatusBadRequest) return } + if len(article.BannerLink) == 0 { http.Error(w, "Bitte ein Titelbild einfügen.", http.StatusBadRequest) return } + article.BannerLink = c.Domain + "/image/serve/" + article.BannerLink + if len(article.Summary) == 0 { http.Error(w, "Bitte die Beschreibung eingeben.", http.StatusBadRequest) return @@ -181,11 +184,12 @@ func ResubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc { return } - bannerLink := c.Domain + "/image/serve/" + r.PostFormValue("article-banner-url") + bannerLink := r.PostFormValue("article-banner-url") if len(bannerLink) == 0 { http.Error(w, "Bitte ein Titelbild einfügen.", http.StatusBadRequest) return } + bannerLink = c.Domain + "/image/serve/" + bannerLink summary := r.PostFormValue("article-summary") if len(summary) == 0 {