looks like 1.4 code. have you checked on how Tools 2 encodes links? On Fri, Jan 7, 2011 at 9:23 AM, Christopher Schultz <ch...@christopherschultz.net> wrote: > 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:f...@bar.com") > .addQueryData('subject', 'Some Subject') > .addQueryData('body', 'Say something smart, here')">mail</a> > > This resulted in the following URL: > > mailto:f...@bar.com?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) > >
--------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org For additional commands, e-mail: user-h...@velocity.apache.org