From 429709dfcb80e04764198adf59eb59e524895a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Alby?= Date: Thu, 14 Mar 2019 10:49:31 -0500 Subject: [PATCH] Merge pull request #1621 from sharelatex/ns-update-spam-regexes allow hyphen in email hostname and ' in project name GitOrigin-RevId: d108b7d42372dee4250157e2830cbc800851afc1 --- services/web/app/coffee/Features/Email/SpamSafe.coffee | 4 ++-- services/web/test/unit/coffee/Email/SpamSafeTests.coffee | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/services/web/app/coffee/Features/Email/SpamSafe.coffee b/services/web/app/coffee/Features/Email/SpamSafe.coffee index 75e207ae9d..26ba49bc15 100644 --- a/services/web/app/coffee/Features/Email/SpamSafe.coffee +++ b/services/web/app/coffee/Features/Email/SpamSafe.coffee @@ -8,8 +8,8 @@ XRegExp = require('xregexp') # https://www.regular-expressions.info/unicode.html#prop is a good resource for # more obscure regex features. standard RegExp does not support these -SAFE_REGEX = XRegExp("^[\\p{L}\\p{N}\\s\\-_!&\\(\\)]+$") -EMAIL_REGEX = XRegExp("^[\\p{L}\\p{N}.+_-]+@[\\w.]+$") +SAFE_REGEX = XRegExp("^[\\p{L}\\p{N}\\s\\-_!'&\\(\\)]+$") +EMAIL_REGEX = XRegExp("^[\\p{L}\\p{N}.+_-]+@[\\w.-]+$") SpamSafe = isSafeUserName: (name) -> diff --git a/services/web/test/unit/coffee/Email/SpamSafeTests.coffee b/services/web/test/unit/coffee/Email/SpamSafeTests.coffee index 10955edcfa..d935dcd0c0 100644 --- a/services/web/test/unit/coffee/Email/SpamSafeTests.coffee +++ b/services/web/test/unit/coffee/Email/SpamSafeTests.coffee @@ -13,8 +13,9 @@ describe "SpamSafe", -> expect(SpamSafe.isSafeUserName('加美汝VX:hihi661,金沙2001005com the first deposit will be _100%_')).to.equal false expect(SpamSafe.isSafeProjectName('Neural Networks: good for your health and will solve all your problems')).to.equal false expect(SpamSafe.isSafeProjectName("An analysis of the questions of the universe!")).to.equal true + expect(SpamSafe.isSafeProjectName("A'p'o's't'r'o'p'h'e gallore")).to.equal true expect(SpamSafe.isSafeProjectName('come buy this => http://www.dopeproduct.com/search/?q=user123')).to.equal false - expect(SpamSafe.isSafeEmail("realistic-email+1@domain.sub.com")).to.equal true + expect(SpamSafe.isSafeEmail("realistic-email+1@domain.sub-hyphen.com")).to.equal true expect(SpamSafe.isSafeEmail("notquiteRight\@evil$.com")).to.equal false expect(SpamSafe.safeUserName("Tammy Weinstįen", "A User")).to.equal "Tammy Weinstįen"