mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-11-22 11:02:42 +03:00
allow + in usernames
This commit is contained in:
parent
130039f5c8
commit
e4d22ebd8b
@ -241,7 +241,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
allowedUsernameRegex = regexp.MustCompile(`^[-_.@a-zA-Z0-9]+$`) // Does not include Everyone (*)
|
||||
allowedUsernameRegex = regexp.MustCompile(`^[-_.+@a-zA-Z0-9]+$`) // Does not include Everyone (*)
|
||||
allowedTopicRegex = regexp.MustCompile(`^[-_A-Za-z0-9]{1,64}$`) // No '*'
|
||||
allowedTopicPatternRegex = regexp.MustCompile(`^[-_*A-Za-z0-9]{1,64}$`) // Adds '*' for wildcards!
|
||||
allowedTierRegex = regexp.MustCompile(`^[-_A-Za-z0-9]{1,64}$`)
|
||||
|
@ -61,3 +61,15 @@ func TestTierContext(t *testing.T) {
|
||||
require.Equal(t, "price_456", context["stripe_yearly_price_id"])
|
||||
|
||||
}
|
||||
|
||||
func TestUsernameRegex(t *testing.T) {
|
||||
username := "phil"
|
||||
username_email := "phil@ntfy.sh"
|
||||
username_email_alias := "phil+alias@ntfy.sh"
|
||||
username_invalid := "phil\rocks"
|
||||
|
||||
require.True(t, AllowedUsername(username))
|
||||
require.True(t, AllowedUsername(username_email))
|
||||
require.True(t, AllowedUsername(username_email_alias))
|
||||
require.False(t, AllowedUsername(username_invalid))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user