diff --git a/.deadcode-out b/.deadcode-out index 58792e25ff..7d3763bf54 100644 --- a/.deadcode-out +++ b/.deadcode-out @@ -305,12 +305,6 @@ package "code.gitea.io/gitea/modules/translation" package "code.gitea.io/gitea/modules/util/filebuffer" func CreateFromReader -package "code.gitea.io/gitea/modules/validation" - func IsValidForgejoActivityPubURL - func IsValidFollowingRepoURL - func IsValidFollowingRepoURLList - func IsOfValidLength - package "code.gitea.io/gitea/modules/web" func RouteMock func RouteMockReset diff --git a/modules/validation/helpers.go b/modules/validation/helpers.go index 415df4154c..13950d9871 100644 --- a/modules/validation/helpers.go +++ b/modules/validation/helpers.go @@ -8,7 +8,6 @@ import ( "net" "net/url" "regexp" - "strconv" "strings" "code.gitea.io/gitea/modules/setting" @@ -118,51 +117,6 @@ func IsValidExternalTrackerURLFormat(uri string) bool { return true } -func IsValidForgejoActivityPubURL(url string) bool { - if !IsValidURL(url) { - return false - } - if !strings.Contains(url, "api/v1/activitypub") { - return false - } - return true -} - -func IsValidFollowingRepoURL(url string) bool { - if !IsValidForgejoActivityPubURL(url) { - return false - } - if !strings.Contains(url, "repository-id") { - return false - } - splitURL := strings.Split(url, "/") - repoIDIndex := len(splitURL) - 1 - // Is there a valid integer denoting a repo id? - if _, err := strconv.Atoi(splitURL[repoIDIndex]); err != nil { - return false - } - return true -} - -func IsValidFollowingRepoURLList(urls string) bool { - switch { - case len(strings.Split(urls, ";")) == 1: - return IsValidFollowingRepoURL(urls) - default: - for _, url := range strings.Split(urls, ";") { - if !IsValidFollowingRepoURLList(url) { - return false - } - } - } - return true -} - -// TODO: use validateable/ValidateMaxLen instead !! -func IsOfValidLength(str string) bool { - return len(str) <= 2048 -} - var ( validUsernamePatternWithDots = regexp.MustCompile(`^[\da-zA-Z][-.\w]*$`) validUsernamePatternWithoutDots = regexp.MustCompile(`^[\da-zA-Z][-\w]*$`)