diff options
author | ayb <ayb@3hg.fr> | 2021-06-26 00:38:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-25 18:38:27 -0400 |
commit | 9b33d18899b7e825e4754969ffcc9d7b541d2d28 (patch) | |
tree | 0e6a0ea1f7062b18cdaa426b3d2eb42d9ca7ac2a /modules/setting/service.go | |
parent | 1a1ce9b7216ab80e94987270da8fc2def57237c0 (diff) | |
download | gitea-9b33d18899b7e825e4754969ffcc9d7b541d2d28.tar.gz gitea-9b33d18899b7e825e4754969ffcc9d7b541d2d28.zip |
Added support for gopher URLs. (#14749)
* Added support for gopher URLs.
* Add setting and make this user settable instead
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/setting/service.go')
-rw-r--r-- | modules/setting/service.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/setting/service.go b/modules/setting/service.go index 41e834e8e6..bd70c7e6eb 100644 --- a/modules/setting/service.go +++ b/modules/setting/service.go @@ -6,6 +6,7 @@ package setting import ( "regexp" + "strings" "time" "code.gitea.io/gitea/modules/log" @@ -55,6 +56,7 @@ var Service struct { AutoWatchOnChanges bool DefaultOrgMemberVisible bool UserDeleteWithCommentsMaxTime time.Duration + ValidSiteURLSchemes []string // OpenID settings EnableOpenIDSignIn bool @@ -120,6 +122,16 @@ func newService() { Service.DefaultOrgVisibilityMode = structs.VisibilityModes[Service.DefaultOrgVisibility] Service.DefaultOrgMemberVisible = sec.Key("DEFAULT_ORG_MEMBER_VISIBLE").MustBool() Service.UserDeleteWithCommentsMaxTime = sec.Key("USER_DELETE_WITH_COMMENTS_MAX_TIME").MustDuration(0) + sec.Key("VALID_SITE_URL_SCHEMES").MustString("http,https") + Service.ValidSiteURLSchemes = sec.Key("VALID_SITE_URL_SCHEMES").Strings(",") + schemes := make([]string, len(Service.ValidSiteURLSchemes)) + for _, scheme := range Service.ValidSiteURLSchemes { + scheme = strings.ToLower(strings.TrimSpace(scheme)) + if scheme != "" { + schemes = append(schemes, scheme) + } + } + Service.ValidSiteURLSchemes = schemes if err := Cfg.Section("service.explore").MapTo(&Service.Explore); err != nil { log.Fatal("Failed to map service.explore settings: %v", err) |