File tree Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -526,7 +526,8 @@ INTERNAL_TOKEN =
526526; ; HMAC to encode urls with, it **is required** if camo is enabled.
527527; HMAC_KEY =
528528; ; Set to true to use camo for https too lese only non https urls are proxyed
529- ; ALLWAYS = false
529+ ; ; ALLWAYS is deprecated and will be removed in the future
530+ ; ALWAYS = false
530531
531532; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
532533; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ func camoHandleLink(link string) string {
3838 if setting .Camo .Enabled {
3939 lnkURL , err := url .Parse (link )
4040 if err == nil && lnkURL .IsAbs () && ! strings .HasPrefix (link , setting .AppURL ) &&
41- (setting .Camo .Allways || lnkURL .Scheme != "https" ) {
41+ (setting .Camo .Always || lnkURL .Scheme != "https" ) {
4242 return CamoEncode (link )
4343 }
4444 }
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ func TestCamoHandleLink(t *testing.T) {
2828 "https://image.proxy/eivin43gJwGVIjR9MiYYtFIk0mw/aHR0cDovL3Rlc3RpbWFnZXMub3JnL2ltZy5qcGc" ,
2929 camoHandleLink ("http://testimages.org/img.jpg" ))
3030
31- setting .Camo .Allways = true
31+ setting .Camo .Always = true
3232 assert .Equal (t ,
3333 "https://gitea.com/img.jpg" ,
3434 camoHandleLink ("https://gitea.com/img.jpg" ))
Original file line number Diff line number Diff line change 33
44package setting
55
6- import "code.gitea.io/gitea/modules/log"
6+ import (
7+ "strconv"
8+
9+ "code.gitea.io/gitea/modules/log"
10+ )
711
812var Camo = struct {
913 Enabled bool
1014 ServerURL string `ini:"SERVER_URL"`
1115 HMACKey string `ini:"HMAC_KEY"`
12- Allways bool
16+ Always bool
1317}{}
1418
1519func loadCamoFrom (rootCfg ConfigProvider ) {
1620 mustMapSetting (rootCfg , "camo" , & Camo )
1721 if Camo .Enabled {
22+ oldValue := rootCfg .Section ("camo" ).Key ("ALLWAYS" ).MustString ("" )
23+ if oldValue != "" {
24+ log .Warn ("camo.ALLWAYS is deprecated, use camo.ALWAYS instead" )
25+ Camo .Always , _ = strconv .ParseBool (oldValue )
26+ }
27+
1828 if Camo .ServerURL == "" || Camo .HMACKey == "" {
1929 log .Fatal (`Camo settings require "SERVER_URL" and HMAC_KEY` )
2030 }
You can’t perform that action at this time.
0 commit comments