浏览代码

Deprecate IMGPROXY_MAX_SRC_DIMENSION

DarthSim 6 年之前
父节点
当前提交
917357616e
共有 3 个文件被更改,包括 6 次插入6 次删除
  1. 4 3
      config.go
  2. 1 2
      docs/configuration.md
  3. 1 1
      download.go

+ 4 - 3
config.go

@@ -200,7 +200,6 @@ var conf = config{
 	Concurrency:           runtime.NumCPU() * 2,
 	TTL:                   3600,
 	IgnoreSslVerification: false,
-	MaxSrcDimension:       8192,
 	MaxSrcResolution:      16800000,
 	AllowInsecure:         false,
 	SignatureSize:         32,
@@ -341,8 +340,10 @@ func init() {
 		log.Fatalf("TTL should be greater than 0, now - %d\n", conf.TTL)
 	}
 
-	if conf.MaxSrcDimension <= 0 {
-		log.Fatalf("Max src dimension should be greater than 0, now - %d\n", conf.MaxSrcDimension)
+	if conf.MaxSrcDimension < 0 {
+		log.Fatalf("Max src dimension should be greater than or equal to 0, now - %d\n", conf.MaxSrcDimension)
+	} else if conf.MaxSrcDimension > 0 {
+		warning("IMGPROXY_MAX_SRC_DIMENSION is deprecated and can be removed in future versions. Use IMGPROXY_MAX_SRC_RESOLUTION")
 	}
 
 	if conf.MaxSrcResolution <= 0 {

+ 1 - 2
docs/configuration.md

@@ -38,9 +38,8 @@ $ echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
 
 ### Security
 
-imgproxy protects you from so-called image bombs. Here is how you can specify maximum image dimensions and resolution which you consider reasonable:
+imgproxy protects you from so-called image bombs. Here is how you can specify maximum image resolution which you consider reasonable:
 
-* `IMGPROXY_MAX_SRC_DIMENSION`: the maximum dimensions of the source image, in pixels, for both width and height. Images with larger actual size will be rejected. Default: `8192`;
 * `IMGPROXY_MAX_SRC_RESOLUTION`: the maximum resolution of the source image, in megapixels. Images with larger actual size will be rejected. Default: `16.8`;
 
 You can also specify a secret to enable authorization with the HTTP `Authorization` header for use in production environments:

+ 1 - 1
download.go

@@ -64,7 +64,7 @@ func initDownloading() {
 }
 
 func checkDimensions(width, height int) error {
-	if width > conf.MaxSrcDimension || height > conf.MaxSrcDimension {
+	if conf.MaxSrcDimension > 0 && (width > conf.MaxSrcDimension || height > conf.MaxSrcDimension) {
 		return errSourceDimensionsTooBig
 	}