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

allow hyphen in email hostname and ' in project name

GitOrigin-RevId: d108b7d42372dee4250157e2830cbc800851afc1
This commit is contained in:
Timothée Alby 2019-03-14 10:49:31 -05:00 committed by sharelatex
parent ca2c854452
commit 429709dfcb
2 changed files with 4 additions and 3 deletions

View file

@ -8,8 +8,8 @@ XRegExp = require('xregexp')
# https://www.regular-expressions.info/unicode.html#prop is a good resource for # https://www.regular-expressions.info/unicode.html#prop is a good resource for
# more obscure regex features. standard RegExp does not support these # more obscure regex features. standard RegExp does not support these
SAFE_REGEX = XRegExp("^[\\p{L}\\p{N}\\s\\-_!&\\(\\)]+$") SAFE_REGEX = XRegExp("^[\\p{L}\\p{N}\\s\\-_!'&\\(\\)]+$")
EMAIL_REGEX = XRegExp("^[\\p{L}\\p{N}.+_-]+@[\\w.]+$") EMAIL_REGEX = XRegExp("^[\\p{L}\\p{N}.+_-]+@[\\w.-]+$")
SpamSafe = SpamSafe =
isSafeUserName: (name) -> isSafeUserName: (name) ->

View file

@ -13,8 +13,9 @@ describe "SpamSafe", ->
expect(SpamSafe.isSafeUserName('加美汝VXhihi661金沙2001005com the first deposit will be _100%_')).to.equal false expect(SpamSafe.isSafeUserName('加美汝VXhihi661金沙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('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("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.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.isSafeEmail("notquiteRight\@evil$.com")).to.equal false
expect(SpamSafe.safeUserName("Tammy Weinstįen", "A User")).to.equal "Tammy Weinstįen" expect(SpamSafe.safeUserName("Tammy Weinstįen", "A User")).to.equal "Tammy Weinstįen"