mirror of
https://github.com/go-gitea/gitea
synced 2024-12-23 00:54:28 +00:00
Backport #32908 by ExplodingDragon It is mentioned in https://man.archlinux.org/man/PKGBUILD.5: 'The variable is not allowed to contain colons, forward slashes, hyphens, or whitespace.' `_` is also an allowed character, and some software in the Arch Linux AUR uses this naming convention. Co-authored-by: Exploding Dragon <explodingfkl@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
a4291fd553
commit
c20642fa99
@ -44,7 +44,8 @@ var (
|
|||||||
|
|
||||||
// https://man.archlinux.org/man/PKGBUILD.5
|
// https://man.archlinux.org/man/PKGBUILD.5
|
||||||
namePattern = regexp.MustCompile(`\A[a-zA-Z0-9@._+-]+\z`)
|
namePattern = regexp.MustCompile(`\A[a-zA-Z0-9@._+-]+\z`)
|
||||||
versionPattern = regexp.MustCompile(`\A(?:[0-9]:)?[a-zA-Z0-9.+~]+(?:-[a-zA-Z0-9.+-~]+)?\z`)
|
// (epoch:pkgver-pkgrel)
|
||||||
|
versionPattern = regexp.MustCompile(`\A(?:\d:)?[\w.+~]+(?:-[-\w.+~]+)?\z`)
|
||||||
)
|
)
|
||||||
|
|
||||||
type Package struct {
|
type Package struct {
|
||||||
|
@ -122,6 +122,14 @@ func TestParsePackageInfo(t *testing.T) {
|
|||||||
assert.ErrorIs(t, err, ErrInvalidName)
|
assert.ErrorIs(t, err, ErrInvalidName)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("Regexp", func(t *testing.T) {
|
||||||
|
assert.Regexp(t, versionPattern, "1.2_3~4+5")
|
||||||
|
assert.Regexp(t, versionPattern, "1:2_3~4+5")
|
||||||
|
assert.NotRegexp(t, versionPattern, "a:1.0.0-1")
|
||||||
|
assert.NotRegexp(t, versionPattern, "0.0.1/1-1")
|
||||||
|
assert.NotRegexp(t, versionPattern, "1.0.0 -1")
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("InvalidVersion", func(t *testing.T) {
|
t.Run("InvalidVersion", func(t *testing.T) {
|
||||||
data := createPKGINFOContent(packageName, "")
|
data := createPKGINFOContent(packageName, "")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user