embedr: handle out-of-range maxwidth; change default (#3713)

zio/stable
bnewbold 2024-04-25 17:23:45 -07:00 committed by GitHub
parent f2797218f8
commit d81a373d21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 4 deletions

View File

@ -122,14 +122,20 @@ func (srv *Server) WebOEmbed(c echo.Context) error {
} }
// TODO: do we actually do something with width? // TODO: do we actually do something with width?
width := 550 width := 600
maxWidthParam := c.QueryParam("maxwidth") maxWidthParam := c.QueryParam("maxwidth")
if maxWidthParam != "" { if maxWidthParam != "" {
maxWidthInt, err := strconv.Atoi(maxWidthParam) maxWidthInt, err := strconv.Atoi(maxWidthParam)
if err != nil || maxWidthInt < 220 || maxWidthInt > 550 { if err != nil {
return c.String(http.StatusBadRequest, "Invalid maxwidth (expected integer between 220 and 550)") 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 // NOTE: maxheight ignored