forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relax generic package filename restrictions (go-gitea#30135)
Now, the chars `=:;()[]{}~!@#$%^ &` are possible as well Fixes go-gitea#30134 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
- Loading branch information
1 parent
1551d73
commit 1ad48f7
Showing
3 changed files
with
91 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2024 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package generic | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestValidatePackageName(t *testing.T) { | ||
bad := []string{ | ||
"", | ||
".", | ||
"..", | ||
"-", | ||
"a?b", | ||
"a b", | ||
"a/b", | ||
} | ||
for _, name := range bad { | ||
assert.False(t, isValidPackageName(name), "bad=%q", name) | ||
} | ||
|
||
good := []string{ | ||
"a", | ||
"1", | ||
"a-", | ||
"a_b", | ||
"c.d+", | ||
} | ||
for _, name := range good { | ||
assert.True(t, isValidPackageName(name), "good=%q", name) | ||
} | ||
} | ||
|
||
func TestValidateFileName(t *testing.T) { | ||
bad := []string{ | ||
"", | ||
".", | ||
"..", | ||
"a?b", | ||
"a/b", | ||
" a", | ||
"a ", | ||
} | ||
for _, name := range bad { | ||
assert.False(t, isValidFileName(name), "bad=%q", name) | ||
} | ||
|
||
good := []string{ | ||
"-", | ||
"a", | ||
"1", | ||
"a-", | ||
"a_b", | ||
"a b", | ||
"c.d+", | ||
`-_+=:;.()[]{}~!@#$%^& aA1`, | ||
} | ||
for _, name := range good { | ||
assert.True(t, isValidFileName(name), "good=%q", name) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters