From d81a373d21af605db43c2076bfe486aa16e01de3 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Thu, 25 Apr 2024 17:23:45 -0700 Subject: embedr: handle out-of-range maxwidth; change default (#3713) --- bskyweb/cmd/embedr/handlers.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'bskyweb/cmd/embedr/handlers.go') diff --git a/bskyweb/cmd/embedr/handlers.go b/bskyweb/cmd/embedr/handlers.go index 5fee7f3a0..a3767eeca 100644 --- a/bskyweb/cmd/embedr/handlers.go +++ b/bskyweb/cmd/embedr/handlers.go @@ -122,14 +122,20 @@ func (srv *Server) WebOEmbed(c echo.Context) error { } // TODO: do we actually do something with width? - width := 550 + width := 600 maxWidthParam := c.QueryParam("maxwidth") if maxWidthParam != "" { maxWidthInt, err := strconv.Atoi(maxWidthParam) - if err != nil || maxWidthInt < 220 || maxWidthInt > 550 { - return c.String(http.StatusBadRequest, "Invalid maxwidth (expected integer between 220 and 550)") + if err != nil { + return c.String(http.StatusBadRequest, "Invalid maxwidth (expected integer)") + } + if maxWidthInt < 220 { + width = 220 + } else if maxWidthInt > 600 { + width = 600 + } else { + width = maxWidthInt } - width = maxWidthInt } // NOTE: maxheight ignored -- cgit 1.4.1