Skip to content

Commit

Permalink
Add simple sanitsation to subscriber name
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Nov 1, 2018
1 parent f9c83e6 commit ad96a43
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions subscribers.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,12 @@ func handleCreateSubscriber(c echo.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
}

req.Email = strings.ToLower(strings.TrimSpace(req.Email))

// Insert and read ID.
var newID int
err := app.Queries.UpsertSubscriber.Get(&newID,
uuid.NewV4(),
req.Email,
req.Name,
strings.ToLower(strings.TrimSpace(req.Email)),
strings.TrimSpace(req.Name),
req.Status,
req.Attribs,
true,
Expand Down Expand Up @@ -227,11 +225,9 @@ func handleUpdateSubscriber(c echo.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, "Invalid length for `name`.")
}

req.Email = strings.ToLower(strings.TrimSpace(req.Email))

_, err := app.Queries.UpdateSubscriber.Exec(req.ID,
req.Email,
req.Name,
strings.ToLower(strings.TrimSpace(req.Email)),
strings.TrimSpace(req.Name),
req.Status,
req.Attribs,
req.Lists)
Expand Down

0 comments on commit ad96a43

Please sign in to comment.