So according to comments on this meta, colons in URLs are automatically encoded if they occur after string position 7.

Unfortunately, this has the side effect of breaking any link which uses the scheme://domain:port syntax because the colon separating the domain and port gets URL encoded (but, deceivingly, still displays properly in the status bar for most browsers when hovering over the link).

Example of problem: my answer on this question

Would it be possible to change the colon-encoding algorithm to only encode colons that follow the first / or ? character after the domain portion?

Edit: The urlencoded colon appears to work okay in Opera, but not in Firefox, Chrome, or IE.


We now encode any colons at position 7 or greater, which are not followed by 2 or more numbers.

  • That should work fine then. Thanks.
    – Dav
    Sep 14 '09 at 1:55

Looks like the link you mentioned in your answer was parsing properly and the colon (:) was not encoded.

Sidenote%3A If you ever want to play around with how something might look between the preview and the final state, take off your shoes and step into the formatting sandbox.

Here's what the status bar shows hovering over the link in your example:

crab on the port

Clicking it brings up the expected URL. Viewing source also displays the colon in the URL as is.

  • Did you try actually viewing the source of the page I linked, or try even clicking on the link at all? The source of the link clearly has a %3a in it where the colon should be.
    – Dav
    Sep 13 '09 at 7:25
  • No your link was not encoded and the : was showing properly.
    – random
    Sep 13 '09 at 7:37
  • Did you view the source? i28.tinypic.com/uyd0i.jpg
    – Dav
    Sep 13 '09 at 7:39
  • Yes, and the link still works.
    – random
    Sep 13 '09 at 7:40
  • On what browser? It's quite possible that only certain browsers properly handle a urlencoded colon there.
    – Dav
    Sep 13 '09 at 7:42
  • The crab in the screenshot lives in Opera.
    – random
    Sep 13 '09 at 7:43
  • Well there you go. Firefox does not properly handle the encoded %3a colon, thus the request stands unless or until the Mozilla team changes that.
    – Dav
    Sep 13 '09 at 7:43
  • On my Win7 box, I could only get it to work in Opera 10. FF3.5.3 showed the proper link in the status bar, but went to the bad encoded url. Both Chrome and IE8 displayed and went to the bad url. Sep 13 '09 at 7:44
  • Worked fine back over in 9.64 of Opera. So it looks like Opera finally plays ball!
    – random
    Sep 13 '09 at 7:45
  • Who is downvoting this fine art? Philistines! Sep 14 '09 at 7:33
  • Downvote was because it didn't match the asker's conditions (FF, IE and Chrome.) and Opera is just too super cool.
    – random
    Sep 14 '09 at 10:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .