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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Crell’s picture

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.

dude4linux’s picture

@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.

Bartezz’s picture

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

Cheers

dude4linux’s picture

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.

Bartezz’s picture

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..

dude4linux’s picture

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.

dude4linux’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Active » Needs review
FileSize
1.29 KB

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.

Crell’s picture

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.

pjcdawkins’s picture

I've re-rolled the patch in #7, so it applies to the latest -dev and 1.1 release, because it seems useful. And I've tested it, but manually...

cerr’s picture

Version: 7.x-1.x-dev » 7.x-1.1

Hi,

I just installed invisimail and it works great except, I still doesn't let em specify the subject. I'm using CKEditor and if i specify the subject, this happens:

 <a href="mailto:info@mydomain.com?subject=Testing">  <span id="7fcabfe4911afec8b5b8fd80ef54fc7b1cfad1d3"></span>
<script type="text/javascript"> <!--
  document.getElementById('7fcabfe4911afec8b5b8fd80ef54fc7b1cfad1d3').innerHTML = '&#105;&#110;&#102;&#111;&#64;&#109;&#121;&#100;&#111;&#109;&#97;&#105;&#110;&#46;&#99;&#111;&#109;';
// --> </script></a>

and like this without the java script:

 <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> 
indigoxela’s picture

Issue summary: View changes

I've applied patch #9 to current stable release 7.x-1.2 and can confirm that it works with email arguments (subject and body).
I'm using filter "Encode email addresses: Javascript-wrapped HTML entities".

Filter "Encode email addresses: HTML entities" is also working fine.

Note: it is absolutely important, that invisimail is the last filter in list.

pjcdawkins’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Needs work » Needs review
Ouach’s picture

The patch #9 worked for me.
Thanks.

MustangGB’s picture

Status: Needs review » Needs work

#9 is not a full re-roll of #7, there are 4 instances that need changing, however #9 only updates 3 of them.

However the missing instance is in $pattern which isn't used anywhere, so I'd say either:
a) Update the missing instance
Or
b) Just remove $pattern altogether

c.nish2k3’s picture

Status: Needs work » Needs review
FileSize
1.03 KB

$pattern is not used. So better to remove it.

MustangGB’s picture

Status: Needs review » Reviewed & tested by the community

Great thanks, looks good and works fine.

TomC’s picture

Version 7.x-1.2 appears to have missed out the patch which allows arguments. Checked the code and the $patterns are:

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

$pattern (e.g.) should read ... href=['\"](mailto:$mail)['\"\?]... etc I believe.

solideogloria’s picture

I was going to make the comment above readable, but never mind.