File URI Specification ?

Thiago Macieira thiago at
Fri Jun 9 22:23:31 EEST 2006

Alexander Larsson wrote:
>I'm not sure what happened to the copy on the freedesktop site. Attached
>is a version i had in my homedir (i wrote the thing). Hopefully its the
>latest version. It might be possible to do some archeological digging
>and find the old one on the site too.

I'm sorry to bring back this old discussion, but I believe the spec is 
actually recommending something that is wrong (file:///). It says:

>Some current apps generate URIs of the form "file:/<path>". These
>are not correct according to RFC1738, so they should not be
>generated. However for backwards compatibility, it is recommended that
>such URIs are interpreted as file URIs with an empty hostname.

Unfortunately, the more-recent RFC 3986 (Jan 2005) clearly indicates that 
this recommendation is, actually, wrong. It shows that, if 
the "authority" part of the URI is empty, the leading two slashes must be 
dropped as well.

See the ABNF syntax:

 URI           = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
 hier-part     = "//" authority path-abempty
               / path-absolute
               / path-rootless
               / path-empty
 authority     = [ userinfo "@" ] host [ ":" port ]
 path-absolute = "/" [ segment-nz *( "/" segment ) ]

This indicates that, if // is present, it must be followed by a non-empty 
hostname. The alternative is to use a path-absolute, which starts with a 
single leading slash.

Technically, the URI also allows for relative paths (without the root), 
but that's relative to the originating document (i.e., file:bin/ls could 
be /usr/local/bin/ls)
Thiago Macieira  -  thiago (AT) - thiago (AT)
  thiago.macieira (AT)     Trolltech AS
    GPG: 0x6EF45358                   |  Sandakerveien 116,
    E067 918B B660 DBD1 105C          |  NO-0402
    966C 33F5 F005 6EF4 5358          |  Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : 

More information about the xdg mailing list