Mailto subject parameters

emdalton - June 22, 2007 - 19:40
Project:SpamSpan filter
Version:6.x-1.4
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Here's yet another format those crazy users want supported:

<a href="mailto:wsbe.alumni@unh.edu?subject=Class%20Notes">Submit a class note</a>

This sets the subject line when the mail application is launched with a new message. While I can certainly appreciate that this starts to push the boundaries of what this relatively simple module was originally intended to do, what can I say -- it's a feature of mailto links, my users keep pasting them in from other websites, and so then we see ugly text like this:

user@domain.edu?subject=Class%20Notes instead of a nice link.

#1

guedressel - June 9, 2009 - 12:35

Hello

+1 for this feature request!

We could need this functionality too - on Drupal 6 site

#2

EvanDonovan - July 16, 2009 - 16:21
Version:5.x-1.3» 6.x-1.3

+1 for this. Currently, mailto links with subject parameter break the filter. I'm bumping the version to 6.x since that's what I'm using, and I don't think you are supposed to have two different issues (one for each version).

#3

lakka - July 19, 2009 - 12:45

What do you mean by "mailto links with subject parameter break the filter"? Are you using the most recent release? It shouldn't break with subject parameters, though it will ignore them.

#4

EvanDonovan - July 20, 2009 - 15:17

I mean that if you have a ?subject parameter in the mailto link the code has an extra span tag that is part of the visible text and the link is broken. I am using the latest version. Note that I am also using the HTML Purifier filter, so it might be an interaction between the two.

#5

lakka - July 20, 2009 - 15:25

Evan,

Please can you post (wrapping in tags as necessary) precisely what html code is output by the spamspan module on your setup, and I'll look into it. If possible, please could you also try with HTML purifier disabled, and tell me what happens then.

#6

EvanDonovan - July 20, 2009 - 17:58

Ok, thanks, I'll try to do this soon. Have a lot of other things to do at work right now :)

#7

geoffreyr - August 3, 2009 - 06:14

+1 for this request, and I'm having a similar issue to EvanDonovan.

HTML in:
<a href="mailto:this.person@example.com?subject=test%20subject">Email link</a>

HTML out:
<a href="mailto:<span class="spamspan"><span class="u">this [dot] person</span><img alt="at" width="10" src="/sites/default/modules/spamspan/image.gif" /><span class="d">example [dot] com</span></span>?subject=test%20subject">Email link</a>

Filters being used:
SpamSpan, URL Filter

Should I try a different combination of filters to see if it gives a similar result?

#8

Bartezz - September 9, 2009 - 07:27

Having similar issues as well with ?subject=
Would be nice to have some more support for the options you have with mailto:

?subject=SpamSpan&body=Please%20support%20more%features&cc=info@mydomain.com

Cheers

#9

sra1 - September 15, 2009 - 23:37

I am having a similar issue as well:

HTML in:

<a href="mailto:fcmit@arizona.edu?subject=Website%20Feedback">fcmit@arizona.edu</a>

HTML out:
<span class="u">fcmit</span><img alt="at" width="10" src="/sites/all/modules/spamspan/image.gif" /><span class="d">arizona [dot] edu</span>?subject=Website%20Feedback"&gt;<span class="spamspan"><span class="u">fcmit</span><img alt="at" width="10" src="/sites/all/modules/spamspan/image.gif" /><span class="d">arizona [dot] edu</span></span></a>

Filters used and order:

Hide email addresses

URL filter

HTML filter

HTML corrector

GMap macro expander

Thanks!

#10

Bartezz - September 16, 2009 - 08:16
Category:feature request» bug report
Priority:normal» critical

As mailto parameters are a standard and also easy to implement with WYSIWYG editors like FCK editor I'm changing this to critical...

This is my markup from node/edit

<p><strong>Per email:</strong><br />
<a href="mailto:mail@domain.com?subject=subjectline&amp;body=bodytext">mail@domain.com</a><br />
</p>

I've only enabled the 'Hide email addresses' filter for the content-type.

This is the source markup that's outputted;

<p><strong>Per email:</strong><br />
<a href="mailto:<span class="spamspan"><span class="u">mail</span><img alt="at" width="10" src="/sites/all/modules/spamspan/image.gif" /><span class="d">domain [dot] com</span></span>?subject=subjectline&amp;body=bodytext"><span class="spamspan"><span class="u">mail</span><img alt="at" width="10" src="/sites/all/modules/spamspan/image.gif" /><span class="d">domain [dot] com</span></span></a><br />
</p>  </div>

Whichs shows itself as

Per email:
maildomain [dot] com?subject=subjectline&body=bodytext">mail@domain.com

Hope this helps fixing the bug!

Cheers

#11

lakka - September 17, 2009 - 12:13
Version:6.x-1.3» 6.x-1.4
Category:bug report» feature request
Priority:critical» normal

This is fixed, in part, by release 1.4 of the module. Mailto: parameters are now silently ignored, and should not break links.

I would appreciate feedback about what markup should be generated from a mailto: link with a subject parameter, and then I'll have a think about how to implement it.

Turning this into a feature request for the time being ...

#12

iva2k - September 17, 2009 - 15:05

subscribe

#13

Bartezz - September 17, 2009 - 19:51

How about

<span class="spamspan"><span class="u">mail</span><img alt="at" width="10" src="/sites/all/modules/spamspan/image.gif" /><span class="d">domain[dot] com</span><span class="s">this%20is%20the%20subject</span><span class="b">this%20is%20the%20body</span></span>

And then make the module add CSS to hide classes

.spamspan span.s, .spamspan span.b {
   display:none;
}

Cheers

#14

siegelp - September 30, 2009 - 20:02
Category:feature request» bug report
Priority:normal» critical

Another big +1 for this feature request.

This is a key feature that we would like to utlilize. There are so many occasions when we need to use the subject function for an email link. Any word on this, possibly building off of Bartezz's suggestion?

Thanks so much for the hard work that has gone/is going into this extremely useful module!

-Pete

#15

lakka - October 3, 2009 - 18:33

OK. You asked for it. Please try version 1.5beta. Mailto: URI parameters should now work. Feedback please

#16

EvanDonovan - October 4, 2009 - 19:52
Status:active» needs review

Thanks. I'll try this in the next week, I hope.

#17

Bartezz - October 4, 2009 - 20:31

Thanx mate, will try monday!

Cheers

#18

Bartezz - October 5, 2009 - 14:55

Hey Lakka,

Not sure what you mean by 'URI parameters should now work'.
My findings are that they now don't result in buggy markup anymore;

<span class="spamspan"><span class="u">info</span><span class="d">mydomain[dot] com</span><span class="h"> (subject: subject, amp, body: bodytext) </span></span>

But clicking a link does not utilize the parameters when opening the email window, is this by design?

Also 'Use a graphical replacement for "@"' doesn't work anymore (see code above). It does work with this option disabled.

Cheers

PS. There aren't settings available for the classname of the new span, nothing big but thought I'd mention it.

#19

lakka - October 5, 2009 - 15:03

I meant that they should work! They do for me.

Please can you let me know exactly what the original input is, and precisely what markup is generated by the filter.

The best way might be for you to upload a text attachment, so that the Drupal issue reporting system does not mangle your html.

Do you mean that "subject" shows up in your email program when you don't use a graphical @, but not when you do? Or do you mean that "subject" never shows up, and also that the graphical @ doesn't work?

#20

Bartezz - October 5, 2009 - 19:19

Hey lakka,

Will post this tomorrow, the exact markup is in the code above!

The graphical markup doesn't work for me at all, and is of no further influence. It's just not being shown (with Javascript turned off).
Subject just never works.

I will try to remove and uninstall and reinistall the module tomorrow and see if that fixes things!

Will post back!
Cheers

#21

Bartezz - October 6, 2009 - 09:17

Ok, still not working :'(

- Uninstalled and removed module. Downloaded again and reinstalled
- Went to admin/settings/filters and set the Full HTML filter to use the Spamspan filter (Hide email addresses using the SpamSpan technique)
- Went to admin/settings/filters/2/configure and checked 'Use a graphical replacement for "@"'
- Set the weights of the filters as followed;
+ Linebreak-converter -10
+ URL-filter -9
+ HTML-corrector -8
+ Hide email addresses using the SpamSpan technique -7

Created a node with the body set to Full HTML and with the following link in the html markup;

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

This results in the following output;

<span class="spamspan"><span class="u">info</span><span class="d">domain [dot] com</span><span class="h"> (subject: subject) </span></span>

The Javascript generated output is;

<a class="spamspan" href="mailto:info@domain.com">info@domain.com</a>

Now I've tried unchecking 'Use a graphical replacement for "@"' and also tried disabling all other filters...
Cleared cache, reasved node each time I changed a setting... nothing!

Using latest D6 release...

Thanx for looking into this!
Cheers

#22

Bartezz - October 6, 2009 - 09:47

FFS! :)

Should have looked at this earlier.... you've forgotten to update the Javascript file...

The compressed version is the old one... I copied the contents of spamspan.js to spamspan.compressed.js and now it works :)
Attached a good newly compressed version of spamspan.compressed.js

Also the next line just might cause the graphical replacement not to work as img tags are filtered out ;)

$output = filter_xss($output, $allowed_tags = array('em', 'strong', 'cite', 'b', 'i', 'code', 'span'));

I've created a patch to fix it and also added this in the patch

$output .= "<span class=\"h\"> (". urldecode(implode(', ', $temp_headers)) .") </span>";

I know a mailto link should normally be url encoded, yet with Javascript off (the way Google looks at your code) it isn't a link anyway, it's just a series of . Might as well make these look good ;)
Otherwhise your output (not source code) looks like this (with Javascript turned off)

info [at] domain [dot] com (subject: A%20lot%20of%20spaces%just%20look%20crap%20when%20url%20encoded)

Cheers

AttachmentSize
spamspan.compressed.zip 478 bytes
spamspan.module.patch 1.07 KB

#23

lakka - October 10, 2009 - 21:41
Priority:critical» normal

Thanks Bartezz. I have committed the right js file this time, and fixed the over-enthusiastic xss filter. I have not used your urldecode patch. I think it is likely to open up a security hole.

All comments on 1.5beta2 are welcome.

#24

Bartezz - October 10, 2009 - 22:14

Hey Lakka,

Thanx for the commit. I would like to see the urldecode patch committed as well tho. It's so ugly to have those %20 and other url encoded stuff on your page or showing up in Google! And I don't see how this can open a security hole when the only thing it does is echoing it to the browser. Maybe we should urldecode and check_plain it... That way it's safe to use and no %20ies will show up... both happy :)

Idea? Then I'll whip up a patch!

Cheers

#25

iva2k - October 15, 2009 - 08:13

Nice work, big progress!

On my test page I got the following testcase work properly now:

<a href="mailto:somebody@example.com?subject=Try It">Email w subj</a>

However, these two do not work in respect to the subject part (subject part is printed in the text, and URL in the link has no subject):

<p>billgates@microsoft.com?subject=Bite Me!</p>
<p>mailto:bg@microsoft.com?subject=Bing Cherry</p>

#26

lakka - October 15, 2009 - 13:17

@iva2k: That's because the first example is not a valid mailto: URI in accordance with RFC 2368. 'Subject' and other headers can only be specified in conjunction with a mailto: URI, and not a normal email address.

The second example is a valid mailto: URI, but you cannot just put a mailto: URI on its own into a document. To make a clickable link, you need to use the mailto: URI as the value of an href attribute. That is certainly my reading of the standards.

#27

Bartezz - October 15, 2009 - 14:55

How about my comment #24 Lakka?

Cheers

#28

iva2k - October 15, 2009 - 14:59
Status:needs review» needs work

@lakka
Thanks for the response, but I think you are missing the point. I gave the text as entered into the body (not using any wysiwyg editors), not SpamSpan's resulting output.

SpamSpan is a filter that takes email text and obfuscates it. My examples are from the node body, which is processed by input filters, including SpamSpan. SpamSpan's output is supposed to be compliant with RFC 2368, not its input, which by the way is handled OK for all 3 examples. The filters allow non-html or non-compliant html to be entered/input into the node, and filters translate/convert/cleanup all input into a valid output HTML.

The first example works as supposed to - SpamSpan formats it in an obfuscated way. So it is check here. It even converts all spaces into %20

The second and third examples are also formatted by SpamSpan, and the results are obfuscated. It is just the "subject" part that is dropped.

>The second example is a valid mailto: URI, but you cannot just put a mailto: URI on its own into a document
Yes I can. The "mailto:URI" is converted to "<a href=URI>..." just fine. And it is one of the reasons I like SpamSpan. It is the case of URI?subject=... that breaks it.

Fortunately, latest changes to handle subject made big improvement in the 2nd & 3rd examples - the resulting links are functional and readable now. They were badly broken before, so it is a huge improvement already. All I point out is that there are some more tweaks needed to make it perfect.

#29

lakka - October 15, 2009 - 15:04
Status:needs work» needs review

@Bartezz - still thinking! The problem is that the filter is not "just echoing to the browser". With your patch, it is decoding the text first, and then outputting it. Code should never output user input without check_plaining it. So it certainly should not output it having doen exactly the reverse! I can't see how using both urldecode and check_plain would help, but I haven't had a chance to try it yet.

 
 

Drupal is a registered trademark of Dries Buytaert.