Skip to content

Commit 19bd41e

Browse files
committed
compare setting once
1 parent f9d6790 commit 19bd41e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

modules/markup/html.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ func visitNode(ctx *RenderContext, procs, textProcs []processor, node *html.Node
386386

387387
attr.Val = util.URLJoin(prefix, attr.Val)
388388
}
389-
if setting.CamoServerURL != "" {
389+
if setting.CamoEnabled {
390390
lnkURL, err := url.Parse(attr.Val)
391391
if err != nil && lnkURL.IsAbs() && !strings.HasPrefix(attr.Val, setting.AppURL) &&
392392
(setting.CamoAllways || lnkURL.Scheme != "https") {

modules/setting/setting.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ var (
196196
PasswordHashAlgo string
197197
PasswordCheckPwn bool
198198
SuccessfulTokensCacheSize int
199+
CamoEnabled bool
199200
CamoServerURL string
200201
CamoHMACKey string
201202
CamoAllways bool
@@ -920,9 +921,12 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
920921
CamoServerURL = sec.Key("CAMO_SERVER_URL").MustString("")
921922
CamoHMACKey = sec.Key("CAMO_HMAC_KEY").MustString("")
922923
CamoAllways = sec.Key("CAMO_ALLWAYS").MustBool(false)
923-
if CamoServerURL != "" && CamoHMACKey == "" {
924-
log.Error("CAMO_SERVER_URL is set but CAMO_HMAC_KEY is empty, skip media proxy settings")
925-
CamoServerURL = ""
924+
if CamoServerURL != "" {
925+
if CamoHMACKey == "" {
926+
log.Error("CAMO_SERVER_URL is set but CAMO_HMAC_KEY is empty, skip media proxy settings")
927+
} else {
928+
CamoEnabled = true
929+
}
926930
}
927931

928932
InternalToken = loadInternalToken(sec)

0 commit comments

Comments
 (0)