diff options
author | bnewbold <bnewbold@robocracy.org> | 2024-04-25 17:23:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 17:23:45 -0700 |
commit | d81a373d21af605db43c2076bfe486aa16e01de3 (patch) | |
tree | 890f1245e6238e266cfe2610d2a7a446eed12189 /bskyweb | |
parent | f2797218f8f59b718ca544b5901e21f35c9ecfe3 (diff) | |
download | voidsky-d81a373d21af605db43c2076bfe486aa16e01de3.tar.zst |
embedr: handle out-of-range maxwidth; change default (#3713)
Diffstat (limited to 'bskyweb')
-rw-r--r-- | bskyweb/cmd/embedr/handlers.go | 14 |
1 files changed, 10 insertions, 4 deletions
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 |