File tree 4 files changed +16
-5
lines changed
4 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -529,7 +529,8 @@ INTERNAL_TOKEN =
529
529
; ; HMAC to encode urls with, it **is required** if camo is enabled.
530
530
; HMAC_KEY =
531
531
; ; Set to true to use camo for https too lese only non https urls are proxyed
532
- ; ALLWAYS = false
532
+ ; ; ALLWAYS is deprecated and will be removed in the future
533
+ ; ALWAYS = false
533
534
534
535
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
535
536
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ func camoHandleLink(link string) string {
38
38
if setting .Camo .Enabled {
39
39
lnkURL , err := url .Parse (link )
40
40
if err == nil && lnkURL .IsAbs () && ! strings .HasPrefix (link , setting .AppURL ) &&
41
- (setting .Camo .Allways || lnkURL .Scheme != "https" ) {
41
+ (setting .Camo .Always || lnkURL .Scheme != "https" ) {
42
42
return CamoEncode (link )
43
43
}
44
44
}
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ func TestCamoHandleLink(t *testing.T) {
28
28
"https://image.proxy/eivin43gJwGVIjR9MiYYtFIk0mw/aHR0cDovL3Rlc3RpbWFnZXMub3JnL2ltZy5qcGc" ,
29
29
camoHandleLink ("http://testimages.org/img.jpg" ))
30
30
31
- setting .Camo .Allways = true
31
+ setting .Camo .Always = true
32
32
assert .Equal (t ,
33
33
"https://gitea.com/img.jpg" ,
34
34
camoHandleLink ("https://gitea.com/img.jpg" ))
Original file line number Diff line number Diff line change 3
3
4
4
package setting
5
5
6
- import "code.gitea.io/gitea/modules/log"
6
+ import (
7
+ "strconv"
8
+
9
+ "code.gitea.io/gitea/modules/log"
10
+ )
7
11
8
12
var Camo = struct {
9
13
Enabled bool
10
14
ServerURL string `ini:"SERVER_URL"`
11
15
HMACKey string `ini:"HMAC_KEY"`
12
- Allways bool
16
+ Always bool
13
17
}{}
14
18
15
19
func loadCamoFrom (rootCfg ConfigProvider ) {
16
20
mustMapSetting (rootCfg , "camo" , & Camo )
17
21
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
+
18
28
if Camo .ServerURL == "" || Camo .HMACKey == "" {
19
29
log .Fatal (`Camo settings require "SERVER_URL" and HMAC_KEY` )
20
30
}
You can’t perform that action at this time.
0 commit comments