2

According to this answer:

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

Unfortunately this breaks links to URLs such as this one: http://www.wowhead.com/zones=8#show:alliance:flightmaster

The link is rendered with the colons encoded and the result is: http://www.wowhead.com/zones=8#show%3aalliance%3aflightmaster

According to this answer, colons are valid characters in hashtags and don't need to be encoded.

Observed in the wild here.

1 Answer 1

3

According to this answer, colons are valid characters in hashtags and don't need to be encoded. (In fact, % is not a valid character in a hashtag.)

I'm not sure we're looking at the same answer here – because what I'm seeing is that percent-encoding is just fine in the fragment.

This is a valid link to the answer:

https://stackoverflow.com/questions/2849756#%32%38%34%39%38%30%30

– granted, IE8 doesn't handle it (I didn't try IE9), but Firefox, Chrome, Safari, and Opera all do the right thing.

Point being: Whether it's necessary or not, it's not illegal. A colon and %3a are semantically identical in URLs per the RFC.

It may be worth thinking about it, since some clients (including, I would assume, many hashbang-like JavaScript handlers) fail to handle it correctly, but your claim that we break the link is wrong.

2
  • Indeed, like your last paragraph kind of states, it's not only about the browser being able to scroll, but about JavaScript using the fragment for further processing. After clicking your encoded example, a simple javascript:alert(document.location.hash); shows the fragment will need some further processing then. But things like meta.stackoverflow.com/users/115866/… (using %2d rather than the dashes) work fine here on SE. ;-) Commented Apr 24, 2011 at 9:32
  • You're right, I misread the answer and % is valid (it's an unencoded % that's invalid). If I'm interpreting the rest correctly however, aren't unencoded colons allowed? Commented Apr 24, 2011 at 14:58

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.