Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URI encoding in Yahoo mail compose link

Tags:

yahoo

I have link generating web app. I'd like to make it easy for users to email the links they create to others using gmail, yahoo mail, etc. Yahoo mail has a particular quirk that I need a workaround for.

If you have a Yahoo mail account, please follow this link:

http://compose.mail.yahoo.com/?body=http%3A%2F%2Flocalhost%3A8000%2Fpath%23anchor

Notice that yahoo redirects to a specific mail server (e.g. http://us.mc431.mail.yahoo.com/mc/compose). As it does, it decodes the hex codes. One of them, %23, is a hash symbol which is not legal in a query string parameter value. All info after %23 is lost.

All my links are broken, and just using another character is not an option.

Calling us.mc431.yahoo.com directly works for me, but probably not for all users, depending on their location.

I've tried setting html=true|false, putting the URL in a html tag. Nothing works. Anyone got a reliable workaround for this particular quirk?

Note: any server-based workaround is a non-starter for me. This has to be a link that's just between Yahoo and the end-user.

Thanks

like image 846
mcqwerty Avatar asked Dec 22 '22 08:12

mcqwerty


2 Answers

Here is how i do it:

  1. run a window.escape on those chars: & ' " # > < \

  2. run a encodeURIComponent on the full string

it works for most of my case. though newline (\n) is still an issue, but I replace \n with space in my case and it worked fine.

like image 128
TaoMin Chang Avatar answered May 16 '23 05:05

TaoMin Chang


I have been dealing with the same problem the last couple of hours and I found a workaround!

If you double-encode the anchor it will be interpreted correctly by Yahoo. That means change %23 to %2523 (the percent-sign is %25 encoded).

So your URI will be:
http://compose.mail.yahoo.com/?body=http%3A%2F%2Flocalhost%3A8000%2Fpath%2523anchor

The same workaround can be used for ampersand. If you only encode that as %26, then Yahoo will convert that to "&amp;" which will discard the rest of message. Same procedure as above - change %26 to %2526.

I still haven't found a solution to the newline-problem though (%0D and %0A).

like image 32
Lasse Avatar answered May 16 '23 07:05

Lasse