From e6f1b14a6aa51e21eedd9a9760fce68a83187819 Mon Sep 17 00:00:00 2001 From: dillon Date: Tue, 11 Aug 2015 11:22:35 -0700 Subject: [PATCH] fix mailto query string to allow 'Subject' as a valid key Summary: Allow 'Subject=' and 'SUBJECT=' as valid keys for 'mailto:' links. Test Plan: Didn't break any tests, so I added a few. Reviewers: bengotow Reviewed By: bengotow Maniphest Tasks: T2415 Differential Revision: https://phab.nylas.com/D1865 --- spec-nylas/stores/draft-store-spec.coffee | 16 ++++++++++++++++ src/flux/stores/draft-store.coffee | 3 +++ 2 files changed, 19 insertions(+) diff --git a/spec-nylas/stores/draft-store-spec.coffee b/spec-nylas/stores/draft-store-spec.coffee index 137cf8edf..e25fa9b3c 100644 --- a/spec-nylas/stores/draft-store-spec.coffee +++ b/spec-nylas/stores/draft-store-spec.coffee @@ -673,6 +673,22 @@ describe "DraftStore", -> DraftStore._onHandleMailtoLink('mailto:bengotow@gmail.com') expect(received.body.indexOf("Edited by TestExtension!")).toBe(0) + it "should be case-insensitive towards subject keys", -> + received = null + spyOn(DraftStore, '_finalizeAndPersistNewMessage').andCallFake (draft) -> + received = draft + Promise.resolve({draftLocalId: 123}) + + expected = "EmailSubjectLOLOL" + DraftStore._onHandleMailtoLink('mailto:asdf@asdf.com?subject=' + expected) + expect(received.subject).toBe(expected) + + DraftStore._onHandleMailtoLink('mailto:asdf@asdf.com?Subject=' + expected) + expect(received.subject).toBe(expected) + + DraftStore._onHandleMailtoLink('mailto:asdf@asdf.com?SUBJECT=' + expected) + expect(received.subject).toBe(expected) + it "should correctly instantiate drafts for a wide range of mailto URLs", -> received = null spyOn(DatabaseStore, 'persistModel').andCallFake (draft) -> diff --git a/src/flux/stores/draft-store.coffee b/src/flux/stores/draft-store.coffee index 4a939f262..83bf476e0 100644 --- a/src/flux/stores/draft-store.coffee +++ b/src/flux/stores/draft-store.coffee @@ -365,6 +365,9 @@ class DraftStore query = require('querystring').parse(query) query.to = to + for key, val of query + query[key.toLowerCase()] = val + draft = new Message body: query.body || '' subject: query.subject || '',