mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-22 23:23:54 +08:00
fix(contacts): Emails only valid if the entire string is the email. (Sentry 2991)
This commit is contained in:
parent
089e5b1c06
commit
7ebb27cdfa
3 changed files with 23 additions and 1 deletions
|
@ -127,6 +127,23 @@ describe "ContactStore", ->
|
|||
results = ContactStore.searchContacts("fi", limit: 6, noPromise: true)
|
||||
expect(results.length).toBe 6
|
||||
|
||||
describe 'isValidContact', ->
|
||||
it "should return true for a variety of valid contacts", ->
|
||||
expect(ContactStore.isValidContact(new Contact(name: 'Ben', email: 'ben@nylas.com'))).toBe(true)
|
||||
expect(ContactStore.isValidContact(new Contact(email: 'ben@nylas.com'))).toBe(true)
|
||||
expect(ContactStore.isValidContact(new Contact(email: 'ben+123@nylas.com'))).toBe(true)
|
||||
|
||||
it "should return false for non-Contact objects", ->
|
||||
expect(ContactStore.isValidContact({name: 'Ben', email: 'ben@nylas.com'})).toBe(false)
|
||||
|
||||
it "should return false if the contact has no email", ->
|
||||
expect(ContactStore.isValidContact(new Contact(name: 'Ben'))).toBe(false)
|
||||
|
||||
it "should return false if the contact has an email that is not valid", ->
|
||||
expect(ContactStore.isValidContact(new Contact(name: 'Ben', email:'Ben <ben@nylas.com>'))).toBe(false)
|
||||
expect(ContactStore.isValidContact(new Contact(name: 'Ben', email:'<ben@nylas.com>'))).toBe(false)
|
||||
expect(ContactStore.isValidContact(new Contact(name: 'Ben', email:'"ben@nylas.com"'))).toBe(false)
|
||||
|
||||
describe 'parseContactsInString', ->
|
||||
testCases =
|
||||
# Single contact test cases
|
||||
|
|
|
@ -113,7 +113,11 @@ class ContactStore extends NylasStore
|
|||
#
|
||||
isValidContact: (contact) =>
|
||||
return false unless contact instanceof Contact
|
||||
return contact.email and RegExpUtils.emailRegex().test(contact.email)
|
||||
return false unless contact.email
|
||||
|
||||
# The email regexp must match the /entire/ email address
|
||||
[match] = RegExpUtils.emailRegex().exec(contact.email)
|
||||
return match is contact.email
|
||||
|
||||
parseContactsInString: (contactString, options={}) =>
|
||||
{skipNameLookup} = options
|
||||
|
|
|
@ -462,6 +462,7 @@ class DraftStore
|
|||
_onSendDraft: (draftClientId) =>
|
||||
if atom.config.get("core.sending.sounds")
|
||||
SoundRegistry.playSound('hit-send')
|
||||
|
||||
@_draftsSending[draftClientId] = true
|
||||
@trigger(draftClientId)
|
||||
|
||||
|
|
Loading…
Reference in a new issue