diff options
author | Wayne Starr <Racer159@users.noreply.github.com> | 2022-11-08 19:10:06 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-09 09:10:06 +0800 |
commit | e054f80fe0e6c6cc2e6a1338abb0c9e260e4d8be (patch) | |
tree | 9ec80c2264e8a67b3685cc66dd6319ccf209494e /routers | |
parent | 89d52922d0cec319430e67add29aa4f5a54b1d03 (diff) | |
download | gitea-e054f80fe0e6c6cc2e6a1338abb0c9e260e4d8be.tar.gz gitea-e054f80fe0e6c6cc2e6a1338abb0c9e260e4d8be.zip |
Allow local package identifiers for PyPI packages (#21690) (#21727)
Backport (#21690)
Fixes #21683
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/packages/pypi/pypi.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/routers/api/packages/pypi/pypi.go b/routers/api/packages/pypi/pypi.go index 3a046abe18..66380d832c 100644 --- a/routers/api/packages/pypi/pypi.go +++ b/routers/api/packages/pypi/pypi.go @@ -25,8 +25,15 @@ import ( var normalizer = strings.NewReplacer(".", "-", "_", "-") var nameMatcher = regexp.MustCompile(`\A[a-zA-Z0-9\.\-_]+\z`) -// https://www.python.org/dev/peps/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions -var versionMatcher = regexp.MustCompile(`^([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$`) +// https://peps.python.org/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions +var versionMatcher = regexp.MustCompile(`\Av?` + + `(?:[0-9]+!)?` + // epoch + `[0-9]+(?:\.[0-9]+)*` + // release segment + `(?:[-_\.]?(?:a|b|c|rc|alpha|beta|pre|preview)[-_\.]?[0-9]*)?` + // pre-release + `(?:-[0-9]+|[-_\.]?(?:post|rev|r)[-_\.]?[0-9]*)?` + // post release + `(?:[-_\.]?dev[-_\.]?[0-9]*)?` + // dev release + `(?:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)?` + // local version + `\z`) func apiError(ctx *context.Context, status int, obj interface{}) { helper.LogAndProcessError(ctx, status, obj, func(message string) { |