Skip to content

Commit

Permalink
Merge branch 'release/1.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dhee-tree committed Oct 2, 2024
2 parents a554e69 + 77ec23f commit e8c31f4
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.22.2-bullseye AS base

ENV GOCACHE=/go/.go/cache GOPATH=/go/.go/path TZ=Europe/London PATH=$PATH:$GOPATH/bin

# Install github.com/cespare/reflex
RUN GOBIN=/bin go install github.com/cespare/[email protected]
RUN GOBIN=/bin go install github.com/kevinburke/go-bindata/v4/[email protected]
RUN PATH=$PATH:/bin

# Clean cache, as we want all modules in the container to be under /go/.go/path
RUN go clean -modcache

# Map between the working directories of dev and live
RUN ln -s /go /dp-frontend-feedback-controller
WORKDIR /dp-frontend-feedback-controller
2 changes: 1 addition & 1 deletion handlers/feedback.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func validateForm(ff *model.FeedbackForm, siteDomain string) (validationErrors [
}

if len(ff.Email) > 0 {
if ok, err := regexp.MatchString(`^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}$`, ff.Email); !ok || err != nil {
if ok, err := regexp.MatchString("^[A-Za-z0-9.`!#$%&'*+-/=?^_{|}~]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}$", ff.Email); !ok || err != nil {
validationErrors = append(validationErrors, core.ErrorItem{
Description: core.Localisation{
LocaleKey: "FeedbackAlertEmail",
Expand Down
56 changes: 56 additions & 0 deletions handlers/feedback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,42 @@ func TestValidateForm(t *testing.T) {
},
},
},
{
givenDescription: "the email field has an invalid special character in local part",
given: &model.FeedbackForm{
Type: mapper.WholeSite,
Description: "A description",
Email: "hello(world)@email.com",
},
expectedDescription: "an email validation error is returned",
expected: []coreModel.ErrorItem{
{
Description: coreModel.Localisation{
LocaleKey: "FeedbackAlertEmail",
Plural: 1,
},
URL: "#email-error",
},
},
},
{
givenDescription: "the email field has invalid domain",
given: &model.FeedbackForm{
Type: mapper.WholeSite,
Description: "A description",
Email: "[email protected]",
},
expectedDescription: "an email validation error is returned",
expected: []coreModel.ErrorItem{
{
Description: coreModel.Localisation{
LocaleKey: "FeedbackAlertEmail",
Plural: 1,
},
URL: "#email-error",
},
},
},
{
givenDescription: "the email field has a valid email address",
given: &model.FeedbackForm{
Expand All @@ -520,6 +556,26 @@ func TestValidateForm(t *testing.T) {
expectedDescription: "no validation errors are returned",
expected: []coreModel.ErrorItem(nil),
},
{
givenDescription: "the email field is valid with special characters",
given: &model.FeedbackForm{
Type: mapper.WholeSite,
Description: "A description",
Email: "hello.hello'[email protected]",
},
expectedDescription: "no validation errors are returned",
expected: []coreModel.ErrorItem(nil),
},
{
givenDescription: "the email field is valid with RFC 3696 special characters",
given: &model.FeedbackForm{
Type: mapper.WholeSite,
Description: "A description",
Email: "hello.`!#$%&'*+-/=?^_{|}[email protected]",
},
expectedDescription: "no validation errors are returned",
expected: []coreModel.ErrorItem(nil),
},
{
givenDescription: "multiple form validation errors",
given: &model.FeedbackForm{
Expand Down
3 changes: 3 additions & 0 deletions reflex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Watch all files ending in .go, excluding files in `.go` or `assets` directory or files
# ending in `_test.go` & run `make debug` when any matching file is changed
-s -r \.go$ -R ^\.go/ -R ^assets/ -R _test\.go$ make debug

0 comments on commit e8c31f4

Please sign in to comment.