URI encoding in Yahoo mail compose link
Asked Answered
L

4

5

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

Luann answered 27/10, 2009 at 17:16 Comment(0)
S
4

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.

Scratch answered 6/12, 2012 at 0:56 Comment(0)
E
3

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

Enloe answered 1/12, 2010 at 11:32 Comment(1)
A combination of %25 and %23 worked for me: http://example.com?foo=%25&bar=http://example.com/%23/bazRhines
S
3

For the newline, add the newline as < BR > and double encode it also, it is interpreted successfully as new line in the new message

Suint answered 3/7, 2011 at 12:34 Comment(0)
J
1

I think you're at the mercy of what Yahoo's server does when it issues the HTTP redirect. It seems like it should preserve the URL escaping on the redirect, but isn't. However, without knowledge of their underlying application, it's hard to say why it wouldn't. Perhaps, it's just an unintended side effect (or bug), or perhaps some of the Javascript features on that page require them to do some finagling with the hash tag.

Jobholder answered 27/10, 2009 at 18:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.