From 596b1045bdbdead07c7fb696082bd05f787c4e54 Mon Sep 17 00:00:00 2001 From: Dmitry Verkhoturov Date: Thu, 3 Nov 2022 21:25:30 +0100 Subject: [PATCH] allow dots in site id during email user validation --- backend/app/rest/api/rest.go | 2 +- backend/app/rest/api/rest_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/rest/api/rest.go b/backend/app/rest/api/rest.go index 56689dc7..a1942838 100644 --- a/backend/app/rest/api/rest.go +++ b/backend/app/rest/api/rest.go @@ -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) { diff --git a/backend/app/rest/api/rest_test.go b/backend/app/rest/api/rest_test.go index c29d49d1..0667da53 100644 --- a/backend/app/rest/api/rest_test.go +++ b/backend/app/rest/api/rest_test.go @@ -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},