Shoutbox

Links ending with a ) - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Links ending with a ) (/showthread.php?tid=95088)

Links ending with a ) by macgyver08 on 07-23-2010 at 08:57 AM

Does anyone know why links that end with a ) turn out like the following when sent through an IM to someone?:

http://en.wikipedia.com/wiki/Angel_(TV_Series)


And I posted this in the scripting section because I'm having my script sometimes send such links, and was hoping someone here may know how to fix this problem.


RE: Links ending with a ) by CookieRevised on 07-23-2010 at 10:14 AM

instead of using ( or ) literally, you should encode them... This because ( and ) are actually reserved characters.

http://en.wikipedia.com/wiki/Angel_%28TV_Series%29

( => %28
) => %29

See http://en.wikipedia.org/wiki/Percent-encoding

This encoding can be done in JScript with the escape() function.

In fact, encoding should always be done when you send URLs which you don't know what they'll be, in any program.

;)


RE: Links ending with a ) by macgyver08 on 07-23-2010 at 11:40 AM

Hmm...it's not very aesthetically pleasing with the percentages in the URL. Is that the only way you know of?


RE: Links ending with a ) by Chris4 on 07-23-2010 at 02:53 PM

A short URL:

http://bit.ly/aEPXZM

A customized short URL:

http://bit.ly/Angel-TV-Series


RE: Links ending with a ) by matty on 07-24-2010 at 06:49 PM

quote:
Originally posted by CookieRevised
( => %29
) => %29
Cookie fail... both parenthesis do not have the same value. It is:
( => %28
) => %29
RE: Links ending with a ) by CookieRevised on 07-25-2010 at 01:41 PM

quote:
Originally posted by matty
quote:
Originally posted by CookieRevised
( => %29
) => %29
Cookie fail... both parenthesis do not have the same value. It is:
( => %28
) => %29
blah.... copy/paste booboo.... :P fixed
quote:
Originally posted by macgyver08
Hmm...it's not very aesthetically pleasing with the percentages in the URL. Is that the only way you know of?
Yes.... because those characters shouldn't be used literally in URLs because they are reserved characters.

Making URLs should be done according to some set standards. Another way would be to use some URL forwarding like Chris4 showed, but those are URLs too and have the exact same rules and need to follow the exact same standards.

This is also explained on http://en.wikipedia.org/wiki/Percent-encoding
RE: Links ending with a ) by Eljay on 07-25-2010 at 02:29 PM

The "escape" method shouldn't be used for this though:

quote:
Originally posted by JScript docs > escape method
Note
The escape method should not be used to encode Uniform Resource Identifiers (URI). Use encodeURI and encodeURIComponent methods instead.

Unfortunately, using encodeURI doesn't encode parentheses (it appears JScript 5.6 is older than the latest RFC about URIs :P) so it doesn't really help.
Although even if they are reserved characters now, Messenger should still match them as part of the URI, so it's a bug.
RE: Links ending with a ) by CookieRevised on 07-25-2010 at 05:33 PM

quote:
Originally posted by Eljay
Unfortunately, using encodeURI doesn't encode parentheses (it appears JScript 5.6 is older than the latest RFC about URIs :P) so it doesn't really help.
Hence why I suggest to use escape() instead (in this situation).

The reason why they suggest not to use escape() has to do with how it handles other characters (eg: it encodes some characters which don't need to be encoded) and that it, therefor, can't be used on a complete link (eg: it also encodes ":" in the "http://" part, and the ampersand & and equal sign = in a query string).

But this is better than not encoding certain characters which should best be encoded (like the parenthesis).

In short, for 'simple' links, in ascii format, without any query components or anchors, the escape() method is a proper (and safer) method to use though as long as you don't include the "http://" part.

Ori: http://www.this.com/that.html (spaced)?data1=1&data2=1#anchor4
escape() => http%3A//www.this.com/that.html%20%28spaced%29%3Fdata1%3D1%26data2%3D1%23anchor4
encodeURI() => http://www.this.com/that.html%20(spaced)?data1=1&data2=1#anchor4


http://xkr.us/articles/javascript/encode-compare/
http://www.the-art-of-web.com/javascript/escape/