Skip to content

Commit ba7da0a

Browse files
lunnyforgejo-backport-action
authored and
forgejo-backport-action
committed
Use camo.Always instead of camo.Allways (go-gitea#32097)
Fix go-gitea#31575 https://gitea.com/gitea/docs/pulls/73 (cherry picked from commit 8e2dd5d) (cherry picked from commit 2ffb08b)
1 parent 74712e3 commit ba7da0a

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

custom/conf/app.example.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,8 @@ INTERNAL_TOKEN =
529529
;; HMAC to encode urls with, it **is required** if camo is enabled.
530530
;HMAC_KEY =
531531
;; 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
533534

534535
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
535536
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

modules/markup/camo.go

+1-1
Original file line numberDiff line numberDiff 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
}

modules/markup/camo_test.go

+1-1
Original file line numberDiff line numberDiff 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"))

modules/setting/camo.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,28 @@
33

44
package setting
55

6-
import "code.gitea.io/gitea/modules/log"
6+
import (
7+
"strconv"
8+
9+
"code.gitea.io/gitea/modules/log"
10+
)
711

812
var 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

1519
func 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
}

0 commit comments

Comments
 (0)