Download & Extend

Support for mailto arguments like ?subject

Project:Invisimail
Version:7.x-1.x-dev
Component:Code
Category:feature request
Priority:major
Assigned:Unassigned
Status:needs work

Issue Summary

I've tried various filters and I like Invisimail, yet I'm missing an important feature.
It doesn't obfuscate mailto links with arguments;

mailto:info@mydomain.com?subject=Hello&body=Dear,&cc=copy@info@mydomain.com

Not good at regular expressions else I would have looked into it myself :(

Cheers

Comments

#1

Version:6.x-1.2» 7.x-1.x-dev
Priority:critical» major

Hm. Yeah, that doesn't work. My regex-fu is almost nil, so I probably wouldn't be able to add that myself either. However, I'd accept a patch that does so.

#2

@Bartezz Do you need to obfuscate the subject and body, or just the e-mail addresses? Might be simpler to do just the latter. I discovered this problem while testing Invisimail using CKEditor to insert the mailto: link. It works as long as the subject and body fields are left blank. I took a look at the code but couldn't figure out where the presence of a '?' would cause the regex match to fail.

#3

Nah I think only email address obfuscation would suffice don't you think? Though what to do with cc= or bcc=

Cheers

#4

I figure it has to be one of the special characters in the extended mailto: that is causing the regex to fail, i.e. either ?, &, or =. I tried

<a href="mailto:info@mydomain.com?subject=Testing">info@mydomain.com</a>

and the result was
<a href="mailto:info@mydomain.com?subject=Testing">&#105;&#110;&#102;&#111;&#64;&#109;&#121;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;</a>

so I think it must be either the ? or =.

Note: I'm looking at the 6.x version, not the 7.x that this issue belongs to.

#5

The original issue by me was in 6.x, Crell changed it to 7.x
My 'regex-fu' also is not legendary... can't really say where the prob lies..

#6

The three regex patterns used by Invisimail assume that the href mailto: address is delimited by quotes ['\"]. I tried adding a '?' to the closing delimiters, i.e. ['\"\?] and it appears to work. By some stroke of luck, the &cc= also works. I presume &bcc works as well, but I didn't test it. I haven't checked the javascript option yet, but will do that next.

$pattern = "@(?:(<a [^>]*href=['\"](mailto:$mail)['\"\?][^>]*>)?((?".">(?<!mailto:))$mail))|(<a [^>]*href=['\"](mailto:$mail)['\"\?][^>]*>(.*?)</a>)@$modifiers";
$pattern_diff_link_text = "@(<a [^>]*href=['\"](mailto:$mail)['\"\?][^>]*>(.*?)</a>)@$modifiers";
$pattern_same_link_text = "@(?:(<a [^>]*href=['\"](mailto:$mail)['\"\?][^>]*>)?((?".">(?<!mailto:))$mail))@$modifiers";

Test Results:
<a href="mailto:info@mydomain.com?subject=Testing">info@mydomain.com</a>
  returns
<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#105;&#110;&#102;&#111;&#64;&#109;&#121;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;?subject=Testing">&#105;&#110;&#102;&#111;&#64;&#109;&#121;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;</a>
and
<a href="mailto:info@mydomain.com?subject=Testing&amp;cc=copy@mydomain.com">info@mydomain.com</a>
  returns
<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#105;&#110;&#102;&#111;&#64;&#109;&#121;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;?subject=Testing&amp;&#99;&#99;&#61;&#99;&#111;&#112;&#121;&#64;&#109;&#121;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;">&#105;&#110;&#102;&#111;&#64;&#109;&#121;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;</a>

I haven't rolled a patch in some time, but if the author thinks it's necessary, I'll give it a try.

#7

Version:7.x-1.x-dev» 6.x-1.x-dev
Status:active» needs review

Decided it was time I learned how to use git to prepare a patch, so here is my first attempt. This patch contains just the mods discussed above in #6.

AttachmentSize
support-mailto-arguments-572356-6.patch 1.29 KB

#8

Version:6.x-1.x-dev» 7.x-1.x-dev
Status:needs review» needs work

Since I don't understand the regexes here in the slightest, we will need unit tests for the regexes at least. (The D7 version of the module doesn't have tests yet, but it should be very easy to write tests for it; they can even be UnitTestCase tests, not WebTestCase tests, so that they run in less than an hour.)

Also, this would be for Drupal 7 only. The Drupal 6 version is not taking any new features as the D7 version is a total rewrite.

nobody click here