feat: disallow {} in member names

This commit is contained in:
Sam 2023-05-02 02:18:35 +02:00
parent a33f39afe5
commit 3f003b5353
No known key found for this signature in database
GPG key ID: B4EF20DDE721CAA1
4 changed files with 4 additions and 4 deletions

View file

@ -35,7 +35,7 @@ const (
)
// member names must match this regex
var memberNameRegex = regexp.MustCompile("^[^@\\?!#/\\\\[\\]\"'$%&()+<=>^|~`,]{1,100}$")
var memberNameRegex = regexp.MustCompile("^[^@\\?!#/\\\\[\\]\"\\{\\}'$%&()+<=>^|~`,]{1,100}$")
func MemberNameValid(name string) bool {
return memberNameRegex.MatchString(name)

View file

@ -80,7 +80,7 @@ func (s *Server) createMember(w http.ResponseWriter, r *http.Request) (err error
if !db.MemberNameValid(cmr.Name) {
return server.APIError{
Code: server.ErrBadRequest,
Details: "Member name cannot contain any of the following: @, ?, !, #, /, \\, [, ], \", ', $, %, &, (, ), +, <, =, >, ^, |, ~, `, ,",
Details: "Member name cannot contain any of the following: @, ?, !, #, /, \\, [, ], \", ', $, %, &, (, ), {, }, +, <, =, >, ^, |, ~, `, ,",
}
}

View file

@ -1,2 +1,2 @@
export const memberNameRegex = /^[^@\\?!#/\\\\[\]"'$%&()+<=>^|~`,]{1,100}$/;
export const memberNameRegex = /^[^@\\?!#/\\\\[\]"\\{\\}'$%&()+<=>^|~`,]{1,100}$/;
export const usernameRegex = /^[\w-.]{2,40}$/;

View file

@ -274,7 +274,7 @@
<p class="text-muted my-2">
<Icon name="info-circle-fill" aria-label="Info" /> Your members must have distinct names. Member
names must be 100 characters long at most, and cannot contain the following characters: @ ?
! # / \ [ ] " ' $ % & ( ) + &lt; = &gt; ^ | ~ ` and ,
! # / \ [ ] " ' $ % & ( ) &lbrace; &rbrace; + &lt; = &gt; ^ | ~ ` and ,
</p>
{#if newMemberError}
<ErrorAlert error={newMemberError} />