All, I'm trying (for the first time!) to create a mailto: link in my webapp and I decided to see what would happen if I used the LinkTool (really StrutsLinkTool) to generate it. Something like this (newlines added for readability):
<a href="$link.setURI("mailto:[email protected]")
.addQueryData('subject', 'Some Subject')
.addQueryData('body', 'Say something smart, here')">mail</a>
This resulted in the following URL:
mailto:[email protected]?subject=some+subject&body=Say+something+smart%2C+here
Normally, this would be a perfectly correct URL. Unfortunately, someone
at some point declared that spaces in mailto: link parameters should be
encoded as "%20" and not "+" [1]. :(
Ignoring the fact that mailto: links are apparently unreliable when
subjects and bodies are added, does anyone have any brilliant ideas of
how to do it?
A simple string.replaceAll(' ', '%20') won't do it, as I'd like to
convert all other characters appropriately and protect against '?' and
'&' characters being included, etc.
I suppose I could do $link.setURI(...).toString().replaceAll('+', '%20')
but that seems completely stupid.
Any ideas?
Thanks,
-chris
[1] http://www.faqs.org/faqs/www/authoring-faq/index.html S(6.10)
signature.asc
Description: OpenPGP digital signature
