mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-05-18 16:25:14 +02:00
remove MaxWidth and MaxHeight options
These were originally added to prevent a denial of service caused by requesting very large images, but are no longer needed since we no longer resize images larger than their original size.
This commit is contained in:
parent
a74e590181
commit
bfbc8ff5ee
2 changed files with 0 additions and 12 deletions
|
|
@ -57,8 +57,6 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
p := imageproxy.NewProxy(nil, c)
|
p := imageproxy.NewProxy(nil, c)
|
||||||
p.MaxWidth = 2000
|
|
||||||
p.MaxHeight = 2000
|
|
||||||
if *whitelist != "" {
|
if *whitelist != "" {
|
||||||
p.Whitelist = strings.Split(*whitelist, ",")
|
p.Whitelist = strings.Split(*whitelist, ",")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
proxy.go
10
proxy.go
|
|
@ -38,9 +38,6 @@ type Proxy struct {
|
||||||
|
|
||||||
// Whitelist specifies a list of remote hosts that images can be proxied from. An empty list means all hosts are allowed.
|
// Whitelist specifies a list of remote hosts that images can be proxied from. An empty list means all hosts are allowed.
|
||||||
Whitelist []string
|
Whitelist []string
|
||||||
|
|
||||||
MaxWidth int
|
|
||||||
MaxHeight int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewProxy constructs a new proxy. The provided http Client will be used to
|
// NewProxy constructs a new proxy. The provided http Client will be used to
|
||||||
|
|
@ -75,13 +72,6 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.MaxWidth > 0 && int(req.Options.Width) > p.MaxWidth {
|
|
||||||
req.Options.Width = float64(p.MaxWidth)
|
|
||||||
}
|
|
||||||
if p.MaxHeight > 0 && int(req.Options.Height) > p.MaxHeight {
|
|
||||||
req.Options.Height = float64(p.MaxHeight)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !p.allowed(req.URL) {
|
if !p.allowed(req.URL) {
|
||||||
glog.Errorf("remote URL is not for an allowed host: %v", req.URL)
|
glog.Errorf("remote URL is not for an allowed host: %v", req.URL)
|
||||||
http.Error(w, fmt.Sprintf("remote URL is not for an allowed host: %v", req.URL), http.StatusBadRequest)
|
http.Error(w, fmt.Sprintf("remote URL is not for an allowed host: %v", req.URL), http.StatusBadRequest)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue