TinyURL Decoder

By setomits Last update May 12, 2011 — Installed 74,234 times.

Problems where Target URL's contain "&"

in
Subscribe to Problems where Target URL's contain "&" 6 posts, 4 voices



Tony Duckles User
FirefoxMacintosh

I'm seeing that any TinyURL's where the _target_ URL has an "&" internally get decoded incorrectly. Since you're using XMLHttpRequest, any "&"'s in the target URL are encoded as "&" in the XML data since XML encodes "&" chars. As a quick fix, I added the following at the end of extract_from_response(), to translate "&amp" back to "&":

   ...
   theUrl = theUrl.replace(/&/g, '&');  // *ted 7/17/09 & -> &
   return theUrl;
 }

Example:
http://bit.ly/AMP3

 
Tony Duckles User
FirefoxMacintosh

Rats, didn't HTML-encode all of the above correctly. The comment in the code-block above is correct, the the text in the reg-ex didn't get encoded correctly. Just to clarify:

  "&"+"amp;" -> "&"

 
setomits Script's Author
FirefoxWindows

Hi Tony Duckles,

Thank you for your report.
I modified and uploaded with your help.

See you.

 
MAEDA Atusi User
FirefoxMacintosh

Hi,
Thanks for the great script setomits.
BTW, it still has problems with URLs with more than one "&" characters.
Example: http://j.mp/deL8Vi

Cheers,

 
MAEDA Atusi User
FirefoxMacintosh

P.S. I think the following should possibly fix the problem:

> cache[_node.href] = finalUrl.replace(/\\|\\/, '').replace('&', '&');
< cache[_node.href] = finalUrl.replace(/\\|\\/, '').replace(/&amp;/g, '&');

 
Jatin Dh User
FirefoxWindows

The quotes were missing. The following does the job for the link posted by MAEDA Atusi

finalUrl.replace(/\\|\\/, '').replace('&/g', '&');

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel