Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are slashes allowed in URL fragment or query?

Tags:

url

My understanding of the general form of a URL is that it looks as follows:

<scheme>://<host><path>?<query>#<fragment>

Can there be any forward slashes in either the query or the fragment? More generally, are there any characters that are specifically reserved for any single part of a URL?

like image 588
Kvass Avatar asked Dec 06 '13 07:12

Kvass


1 Answers

STD 66 defines the fragment as:

fragment = *( pchar / "/" / "?" )

So aside from characters from the pchar set (unreserved / pct-encoded / sub-delims / ":" / "@"), the / and the ? can be used in the fragment directly (i.e., percent-encoding is not needed).

The / is even mentioned explicitly in the text:

The characters slash ("/") and question mark ("?") are allowed to represent data within the fragment identifier. Beware that some older, erroneous implementations may not handle this data correctly when it is used as the base URI for relative references (Section 5.1).

like image 175
unor Avatar answered Sep 28 '22 02:09

unor