Просмотр исходного кода

Merge pull request #1621 from sharelatex/ns-update-spam-regexes

allow hyphen in email hostname and ' in project name

GitOrigin-RevId: d108b7d42372dee4250157e2830cbc800851afc1
Timothée Alby 7 лет назад
Родитель
Сommit
429709dfcb

+ 2 - 2
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) ->

+ 2 - 1
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"