Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple fragment identifiers correct in URL?

I stumbled across a site that uses multiple fragment identifiers in their URLs, like http://www.ejeby.se/#newprodukt#produkt#1075#1 (no, it is not my site, but I am linking to it, which brings problems for me).

But is this really correct? It does seem to cause problems for Safari and possibly also Internet Explorer (hearsay, I have not tried IE myself).

Isn't the fragment identifier supposed to uniquely identify one location in the document? Is this a bug in Safari or is it www.ejeby.se that uses fragment idenifiers in a wrong way?

Edit: Seems that the problem for Safari is that it escapes all # but the first in the URL. The other browsers do not do this. Correct behaviour or not?

like image 751
Johan Avatar asked Jan 17 '11 14:01

Johan


1 Answers

From the specification point of view, a fragment can contain the following characters (I’ve already expanded the productions):

fragment    = *( ALPHA / DIGIT / "-" / "." / "_" / "~" / "%" HEXDIG HEXDIG / "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" / ":" / "@" / "/" / "?" )

So, no, the fragment must not contain a plain #; it must be encoded with %23.

But it is possible that some browsers display it differently just as sequences of percent-encoded octets, that represent valid UTF-8 characters are replaced by the characters they represent.

like image 194
Gumbo Avatar answered Oct 11 '22 14:10

Gumbo