summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2022-07-13 09:07:16 +0800
committerGitHub <noreply@github.com>2022-07-13 09:07:16 +0800
commitf67a1030b308a24cca13ff788f7b7119f0404580 (patch)
tree2f5d8777096f84bf4443070fa379ec4fd3034332 /modules
parentd94f517643480369665eb37db31c9ddd700e07b3 (diff)
downloadgitea-f67a1030b308a24cca13ff788f7b7119f0404580.tar.gz
gitea-f67a1030b308a24cca13ff788f7b7119f0404580.zip
Add tests for the host checking logic, clarify the behaviors (#20328)
Before, the combination of AllowedDomains/BlockedDomains/AllowLocalNetworks is confusing. This PR adds tests for the logic, clarify the behaviors.
Diffstat (limited to 'modules')
-rw-r--r--modules/hostmatcher/hostmatcher.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/hostmatcher/hostmatcher.go b/modules/hostmatcher/hostmatcher.go
index 00bbc6cb0a..81c4202fcd 100644
--- a/modules/hostmatcher/hostmatcher.go
+++ b/modules/hostmatcher/hostmatcher.go
@@ -125,14 +125,14 @@ func (hl *HostMatchList) checkIP(ip net.IP) bool {
// MatchHostName checks if the host matches an allow/deny(block) list
func (hl *HostMatchList) MatchHostName(host string) bool {
+ if hl == nil {
+ return false
+ }
+
hostname, _, err := net.SplitHostPort(host)
if err != nil {
hostname = host
}
-
- if hl == nil {
- return false
- }
if hl.checkPattern(hostname) {
return true
}