This commit is contained in:
Blake Stoddard 2026-04-03 01:12:06 +00:00 committed by GitHub
commit 8f5f627534
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -256,12 +256,11 @@ func (p *Proxy) serveImage(w http.ResponseWriter, r *http.Request) {
req.Options.ScaleUp = p.ScaleUp req.Options.ScaleUp = p.ScaleUp
actualReq, _ := http.NewRequest("GET", req.String(), nil) actualReq, _ := http.NewRequest("GET", req.String(), nil)
actualReq.Header.Set("Accept", "*/*")
actualReq.Header.Set("Accept-Language", "*")
if p.UserAgent != "" { if p.UserAgent != "" {
actualReq.Header.Set("User-Agent", p.UserAgent) actualReq.Header.Set("User-Agent", p.UserAgent)
} }
if len(p.ContentTypes) != 0 {
actualReq.Header.Set("Accept", strings.Join(p.ContentTypes, ", "))
}
if p.IncludeReferer { if p.IncludeReferer {
// pass along the referer header from the original request // pass along the referer header from the original request
copyHeader(actualReq.Header, r.Header, "referer") copyHeader(actualReq.Header, r.Header, "referer")
@ -335,7 +334,7 @@ func (p *Proxy) serveImage(w http.ResponseWriter, r *http.Request) {
resp.Body = io.NopCloser(b) resp.Body = io.NopCloser(b)
contentType = peekContentType(b) contentType = peekContentType(b)
} }
if resp.ContentLength != 0 && !contentTypeMatches(p.ContentTypes, contentType) { if (resp.ContentLength != 0 && !contentTypeMatches(p.ContentTypes, contentType)) || strings.Contains(contentType, "svg") {
p.logf("content-type not allowed: %q", contentType) p.logf("content-type not allowed: %q", contentType)
http.Error(w, msgNotAllowed, http.StatusForbidden) http.Error(w, msgNotAllowed, http.StatusForbidden)
return return