Skip to content

Commit

Permalink
allow dots in site id during email user validation
Browse files Browse the repository at this point in the history
  • Loading branch information
paskal authored and umputun committed Nov 3, 2022
1 parent 907ca2b commit 596b104
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion backend/app/rest/api/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ func subscribersOnly(enable bool) func(http.Handler) http.Handler {
func validEmailAuth() func(http.Handler) http.Handler {

reUser := regexp.MustCompile(`^[\p{L}\d\s_]{4,64}$`) // matches ui side validation, adding min/max limitation
reSite := regexp.MustCompile(`^[a-zA-Z\d\s_-]{1,64}$`)
reSite := regexp.MustCompile(`^[a-zA-Z\d\s_.-]{1,64}$`)

return func(h http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion backend/app/rest/api/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func Test_validEmailAuth(t *testing.T) {
status int
}{
{"/auth/email/login?site=remark42&address=umputun%example.com&user=someone", http.StatusOK},
{"/auth/email/login?site=site-with-dash_and_underscore&address=umputun%example.com&user=someone", http.StatusOK},
{"/auth/email/login?site=site-with-dash_and_underscore-and.dot&address=umputun%example.com&user=someone", http.StatusOK},
{"/auth/email/login?site=remark42&address=umputun%example.com&user=someone+blah", http.StatusOK},
{"/auth/email/login?site=remark42&address=umputun%example.com&user=Евгений+Умпутун", http.StatusOK},
{"/auth/email/login?site=remark42&address=umputun%example.com&user=12", http.StatusForbidden},
Expand Down

0 comments on commit 596b104

Please sign in to comment.