mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-11 02:30:21 +08:00
fix(mailto): test case / parsing for url encoded To field
This commit is contained in:
parent
cbfe310521
commit
3d3f7fa315
2 changed files with 12 additions and 5 deletions
|
@ -897,6 +897,7 @@ describe "DraftStore", ->
|
|||
'mailto:'
|
||||
'mailto://bengotow@gmail.com'
|
||||
'mailto:bengotow@gmail.com'
|
||||
'mailto:mg%40nylas.com'
|
||||
'mailto:?subject=%1z2a', # fails uriDecode
|
||||
'mailto:?subject=%52z2a', # passes uriDecode
|
||||
'mailto:?subject=Martha Stewart',
|
||||
|
@ -919,6 +920,9 @@ describe "DraftStore", ->
|
|||
new Message(
|
||||
to: [new Contact(name: 'bengotow@gmail.com', email: 'bengotow@gmail.com')]
|
||||
),
|
||||
new Message(
|
||||
to: [new Contact(name: 'mg@nylas.com', email: 'mg@nylas.com')]
|
||||
),
|
||||
new Message(
|
||||
subject: '%1z2a'
|
||||
),
|
||||
|
@ -986,8 +990,8 @@ describe "DraftStore", ->
|
|||
expect(received['subject']).toEqual(expectedDraft['subject'])
|
||||
expect(received['body']).toEqual(expectedDraft['body']) if expectedDraft['body']
|
||||
['to', 'cc', 'bcc'].forEach (attr) ->
|
||||
received[attr].forEach (contact, jdx) ->
|
||||
expect(contact instanceof Contact).toBe(true)
|
||||
expectedContact = expectedDraft[attr][jdx]
|
||||
expect(contact.email).toEqual(expectedContact.email)
|
||||
expect(contact.name).toEqual(expectedContact.name)
|
||||
expectedDraft[attr].forEach (expected, jdx) ->
|
||||
actual = received[attr][jdx]
|
||||
expect(actual instanceof Contact).toBe(true)
|
||||
expect(actual.email).toEqual(expected.email)
|
||||
expect(actual.name).toEqual(expected.name)
|
||||
|
|
|
@ -424,6 +424,9 @@ class DraftStore
|
|||
|
||||
[whole, to, queryString] = /mailto:\/*([^\?\&]*)((.|\n|\r)*)/.exec(urlString)
|
||||
|
||||
if to.length > 0 and to.indexOf('@') is -1
|
||||
to = decodeURIComponent(to)
|
||||
|
||||
# /many/ mailto links are malformed and do things like:
|
||||
# &body=https://github.com/atom/electron/issues?utf8=&q=is%3Aissue+is%3Aopen+123&subject=...
|
||||
# (note the unescaped ? and & in the URL).
|
||||
|
|
Loading…
Reference in a new issue