URI encoding in Yahoo mail compose link

风格不统一 提交于 2019-11-28 04:39:49

问题


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


回答1:


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.




回答2:


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




回答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




回答4:


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.



来源:https://stackoverflow.com/questions/1632335/uri-encoding-in-yahoo-mail-compose-link

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!