From 0254687d5b97dd8299a2b55d26c39599c42fb364 Mon Sep 17 00:00:00 2001 From: Azareal Date: Tue, 16 Jun 2020 13:25:38 +1000 Subject: [PATCH] oh --- common/utils.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/common/utils.go b/common/utils.go index 3c49f8a0..49be76c6 100644 --- a/common/utils.go +++ b/common/utils.go @@ -341,7 +341,7 @@ func NameToSlug(name string) (slug string) { func HasSuspiciousEmail(email string) bool { lowEmail := strings.ToLower(email) // TODO: Use a more flexible blacklist, perhaps with a similar mechanism to the HTML tag registration system in PreparseMessage() - if strings.Contains(lowEmail, "casino") || strings.Contains(lowEmail, "viagra") || strings.Contains(lowEmail, "pharma") || strings.Contains(lowEmail, "pill") { + if !strings.Contains(lowEmail,"@") || strings.Contains(lowEmail, "casino") || strings.Contains(lowEmail, "viagra") || strings.Contains(lowEmail, "pharma") || strings.Contains(lowEmail, "pill") { return true } @@ -438,6 +438,19 @@ func WeakPassword(password, username, email string) error { return nil } +// TODO: Write a test for this +func CanonEmail(email string) string { + email = strings.ToLower(email) + + // Gmail emails are equivalent without the dots + espl := strings.Split(email, "@") + if len(espl) >= 2 && espl[1] == "gmail.com" { + return strings.Replace(espl[0],".","",-1) + "@" + espl[1] + } + + return email +} + // TODO: Write a test for this func createFile(name string) error { f, err := os.Create(name)