<?xml version="1.0" encoding="UTF-8"?>
  <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
  <!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.0.39 -->

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
]>

<?rfc toc="yes"?>
<?rfc tocindent="yes"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>
<?rfc strict="yes"?>
<?rfc compact="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>

<rfc ipr="trust200902" docName="draft-ietf-appsawg-file-scheme-15" category="std" updates="1738">

  <front>
    <title abbrev="file-scheme">The file URI Scheme</title>

    <author initials="M." surname="Kerwin" fullname="Matthew Kerwin">
      <organization abbrev="QUT">Queensland University of Technology</organization>
      <address>
        <postal>
          <street>Victoria Park Road</street>
          <city>Kelvin Grove</city>
          <region>QLD</region>
          <code>4059</code>
          <country>Australia</country>
        </postal>
        <email>matthew.kerwin@qut.edu.au</email>
      </address>
    </author>

    <date year="2016"/>

    <area>General</area>
    <workgroup>Applications Area Working Group</workgroup>
    <keyword>Internet-Draft</keyword>

    <abstract>


<t>This document provides a more complete specification of the “file”
Uniform Resource Identifier (URI) scheme, replacing the very brief
definition in Section 3.10 of RFC 1738.</t>

<t>It defines a common syntax which is intended to interoperate across
the broad spectrum of existing usages.  At the same time it notes
some other current practices around the use of file URIs.</t>



    </abstract>


    <note title="Note to Readers (To be removed by the RFC Editor)">


<t>This draft should be discussed on the IETF Applications Area Working
Group discussion list &lt;apps-discuss@ietf.org&gt;.</t>


    </note>


  </front>

  <middle>


<section anchor="introduction" title="Introduction">

<t>A file URI identifies an object (a “file”) stored in a structured
object naming and accessing environment on a host (a “file system.”)
The URI can be used in discussions about the file, and if other
conditions are met it can be dereferenced to directly access the file.</t>

<t>This document specifies a syntax based on the generic syntax of
<xref target="RFC3986"/> that is compatible with most existing usages.  Where
incompatibilities arise they are usually in parts of the scheme that
were underspecified in earlier definitions and have been tightened up
by more recent specifications.  <xref target="diff"/> lists significant changes to
syntax.</t>

<t>Extensions to the syntax which might be encountered in practice are
listed in <xref target="nonstandard-syntax"/>;  these extensions are listed for
informational purposes and are not a requirement of implementation.</t>

<t>The file URI scheme is not coupled with a specific protocol, nor with a
specific media type <xref target="RFC6838"/>.  See <xref target="operations"/> for a discussion
of operations that can be performed on the object identified by a file
URI.</t>

<section anchor="notational-conventions" title="Notational Conventions">

<t>The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”,
“SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this
document are to be interpreted as described in <xref target="RFC2119"/> when they
appear in all upper case.  They may also appear in lower or mixed case
as English words, without normative meaning.</t>

<t>Throughout this document the term “local file” is used to describe
files that can be accessed through the local file system API using only
the information included in the file path, not relying on other
information (such as network addresses.)  It is important to note that
a local file may not be physically located on the local machine, for
example if a networked file system is transparently mounted into the
local file system.</t>

<t>The term “local file URI” is used to describe file URIs which have
no <spanx style="verb">authority</spanx> component, or where the authority is the special string
“localhost” or a fully qualified domain name that resolves to the
machine from which the URI is being interpreted (<xref target="syntax"/>).</t>

</section>
</section>
<section anchor="syntax" title="Syntax">

<t>The file URI syntax is defined here in Augmented Backus-Naur Form (ABNF)
<xref target="RFC5234"/>, importing the <spanx style="verb">host</spanx> and <spanx style="verb">path-absolute</spanx> rules from
<xref target="RFC3986"/> (as updated by <xref target="RFC6874"/>.)</t>

<t>The generic syntax in <xref target="RFC3986"/> includes <spanx style="verb">path</spanx> and <spanx style="verb">authority</spanx>
components, for each of which only a subset is used in the definition
of the file URI scheme.  The relevant subset of <spanx style="verb">path</spanx> is
<spanx style="verb">path-absolute</spanx>, and the subset of <spanx style="verb">authority</spanx> is <spanx style="verb">file-auth</spanx>, given
below.</t>

<t>The syntax definition below is different from those given in
<xref target="RFC1630"/> and <xref target="RFC1738"/> as it is derived from the generic syntax
of <xref target="RFC3986"/>, which post-dates the previous file URI specifications.
<xref target="diff"/> enumerates significant differences.</t>

<figure><artwork><![CDATA[
   file-URI       = file-scheme ":" file-hier-part

   file-scheme    = "file"

   file-hier-part = ( "//" auth-path )
                  / local-path

   auth-path      = [ file-auth ] path-absolute

   local-path     = path-absolute

   file-auth      = "localhost"
                  / host
]]></artwork></figure>

<t>The <spanx style="verb">host</spanx> is the fully qualified domain name of the system on which
the file is accessible.  This allows a client on another system to know
that it cannot access the file system, or perhaps that it needs to use
some other local mechanism to access the file.</t>

<t>As a special case, the <spanx style="verb">file-auth</spanx> rule can match the string
“localhost” which is interpreted as “the machine from which the URI is
being interpreted,” exactly as if no authority were present.
Some current usages of the scheme incorrectly interpret all values in
the authority of a file URI, including “localhost”, as non-local.
Yet others interpret any value as local, even if the <spanx style="verb">host</spanx> does not
resolve to the local machine.
To maximize compatibility with previous specifications, users MAY
choose to include an <spanx style="verb">auth-path</spanx> with no <spanx style="verb">file-auth</spanx> when creating a
URI.</t>

<t>The path component represents the absolute path to the file in the file
system.  See <xref target="system-specific"/> for some discussion of system-specific
concerns including absolute file paths and file system roots.</t>

<t>Some file systems have case-sensitive file naming and some do not.  As
such the file URI scheme supports case sensitivity, in order to retain
the case as given.  Any transport-related handling of the file URI
scheme MUST retain the case as given.  Any mapping to or from a
case-insensitive form is solely the responsibility of the implementation
processing the file URI on behalf of the referenced file system.</t>

<t>Also see <xref target="nonstandard-syntax"/> that lists some nonstandard syntax
variations that can be encountered in practice.</t>

</section>
<section anchor="operations" title="Operations Involving file URIs">

<t>See the POSIX file and directory operations <xref target="POSIX"/> for examples of
standardized operations that can be performed on files.</t>

<t>A file URI can be dependably dereferenced or translated to a local file
path only if it is local.  A file URI is considered “local” if it has
no <spanx style="verb">file-auth</spanx>, or the <spanx style="verb">file-auth</spanx> is the special string “localhost” or
a fully qualified domain name that resolves to the machine from which
the URI is being interpreted (<xref target="syntax"/>).</t>

<t>This specification neither defines nor forbids any set of operations
that might be performed on a file identified by a non-local file URI.</t>

</section>
<section anchor="encoding" title="File System Name Encoding">

<t>File systems use various encoding schemes to store file and directory
names.  Many modern file systems store file and directory names as
arbitrary sequences of octets, in which case the representation as an
encoded string often depends on the user’s localization settings, or
defaults to UTF-8 <xref target="STD63"/>.</t>

<t>When a file URI is produced that represents textual data consisting of
characters from the Unicode Standard coded character set <xref target="UNICODE"/>,
the data SHOULD be encoded as octets according to the UTF-8 character
encoding scheme <xref target="STD63"/> before percent-encoding is applied; as per
<xref target="RFC3986"/>, Section 2.5.</t>

<t>A decision not to use percent-encoded UTF-8 is outside the scope of
this specification.  It will typically require the use of heuristics or
explicit knowledge about the way the string will be processed.</t>

</section>
<section anchor="security" title="Security Considerations">

<t>There are many security considerations for URI schemes discussed in
<xref target="RFC3986"/>.</t>

<t>File access and the granting of privileges for specific operations
are complex topics, and the use of file URIs can complicate the
security model in effect for file privileges.</t>

<t>Historically, user agents have granted content from the file URI
scheme a tremendous amount of privilege.  However, granting all local
files such wide privileges can lead to privilege escalation attacks.
Some user agents have had success granting local files directory-based
privileges, but this approach has not been widely adopted.  Other user
agents use globally unique identifiers as the origin for each file URI
<xref target="RFC6454"/>, which is the most secure option.</t>

<t>Treating a non-local file URI as local or otherwise attempting to
perform local operations on a non-local URI can result in security
problems.
<!-- Barry Lieba - 2016-11-30 --></t>

<t>File systems typically assign an operational meaning to special
characters, such as the “/”, “\”, “:”, “[”, and “]” characters, and
to special device names like “.”, “..”, “…”, “aux”, “lpt”, etc.
In some cases, merely testing for the existence of such a name will
cause the operating system to pause or invoke unrelated system calls,
leading to significant security concerns regarding denial of service
and unintended data transfer.  It would be impossible for this
specification to list all such significant characters and device names.
Implementers MUST research the reserved names and characters for the
types of storage device that may be attached to their application and
restrict the use of data obtained from URI components accordingly.</t>

<t>File systems vary in the way they handle case.  Care MUST be taken to
avoid issues resulting from possibly unexpected aliasing from case-only
differences between file paths or URIs, or from mismatched encodings or
Unicode equivalences <xref target="UAX15"/> (see <xref target="encoding"/>).</t>

</section>
<section anchor="iana-considerations" title="IANA Considerations">

<t>This document defines the following URI scheme, so the “Permanent
URI Schemes” registry has been updated accordingly.  This registration
complies with <xref target="BCP35"/>.</t>

<t><list style="hanging">
  <t hangText='Scheme name:'><vspace blankLines='0'/>
  file</t>
  <t hangText='Status:'><vspace blankLines='0'/>
  permanent</t>
  <t hangText='Applications/protocols that use this scheme name:'><vspace blankLines='0'/>
  Commonly used in hypertext documents to refer to files without
depending on network access.  Supported by major browsers.</t>
  <t>Used in development libraries, such as:

      <list style="symbols">
        <t>Windows Shell (PathCreateFromUrl, UrlCreateFromPath).</t>
        <t>libwww-perl - The World-Wide Web library for Perl.</t>
      </list>
  </t>
  <t hangText='Contact:'><vspace blankLines='0'/>
  Applications and Real-Time Area &lt;art@ietf.org&gt;</t>
  <t hangText='Change Controller:'><vspace blankLines='0'/>
  This scheme is registered under the IETF tree.  As such, the IETF
maintains change control.</t>
  <t hangText='References:'><vspace blankLines='0'/>
  This RFC.</t>
</list></t>

</section>
<section anchor="acknowledgements" title="Acknowledgements">

<t>Contributions from many members of the IETF and W3C communities –
notably Dave Crocker, Graham Klyne, Tom Petch, and John Klensin – are
greatly appreciated.</t>

<t>Additional thanks to Dave Risney, author of the informative IE Blog article
&lt;http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx&gt;,
and Dave Thaler for their early comments and suggestions; and to Paul
Hoffman, whose earlier work served as an inspiration for this undertaking.</t>

</section>


  </middle>

  <back>

    <references title='Normative References'>





<reference  anchor='RFC2119' target='http://www.rfc-editor.org/info/rfc2119'>
<front>
<title>Key words for use in RFCs to Indicate Requirement Levels</title>
<author initials='S.' surname='Bradner' fullname='S. Bradner'><organization /></author>
<date year='1997' month='March' />
<abstract><t>In many standards track documents several words are used to signify the requirements in the specification.  These words are often capitalized. This document defines these words as they should be interpreted in IETF documents.  This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t></abstract>
</front>
<seriesInfo name='BCP' value='14'/>
<seriesInfo name='RFC' value='2119'/>
<seriesInfo name='DOI' value='10.17487/RFC2119'/>
</reference>



<reference  anchor='RFC3986' target='http://www.rfc-editor.org/info/rfc3986'>
<front>
<title>Uniform Resource Identifier (URI): Generic Syntax</title>
<author initials='T.' surname='Berners-Lee' fullname='T. Berners-Lee'><organization /></author>
<author initials='R.' surname='Fielding' fullname='R. Fielding'><organization /></author>
<author initials='L.' surname='Masinter' fullname='L. Masinter'><organization /></author>
<date year='2005' month='January' />
<abstract><t>A Uniform Resource Identifier (URI) is a compact sequence of characters that identifies an abstract or physical resource.  This specification defines the generic URI syntax and a process for resolving URI references that might be in relative form, along with guidelines and security considerations for the use of URIs on the Internet.  The URI syntax defines a grammar that is a superset of all valid URIs, allowing an implementation to parse the common components of a URI reference without knowing the scheme-specific requirements of every possible identifier.  This specification does not define a generative grammar for URIs; that task is performed by the individual specifications of each URI scheme.  [STANDARDS-TRACK]</t></abstract>
</front>
<seriesInfo name='STD' value='66'/>
<seriesInfo name='RFC' value='3986'/>
<seriesInfo name='DOI' value='10.17487/RFC3986'/>
</reference>



<reference  anchor='RFC5234' target='http://www.rfc-editor.org/info/rfc5234'>
<front>
<title>Augmented BNF for Syntax Specifications: ABNF</title>
<author initials='D.' surname='Crocker' fullname='D. Crocker' role='editor'><organization /></author>
<author initials='P.' surname='Overell' fullname='P. Overell'><organization /></author>
<date year='2008' month='January' />
<abstract><t>Internet technical specifications often need to define a formal syntax.  Over the years, a modified version of Backus-Naur Form (BNF), called Augmented BNF (ABNF), has been popular among many Internet specifications.  The current specification documents ABNF. It balances compactness and simplicity with reasonable representational power.  The differences between standard BNF and ABNF involve naming rules, repetition, alternatives, order-independence, and value ranges.  This specification also supplies additional rule definitions and encoding for a core lexical analyzer of the type common to several Internet specifications.  [STANDARDS-TRACK]</t></abstract>
</front>
<seriesInfo name='STD' value='68'/>
<seriesInfo name='RFC' value='5234'/>
<seriesInfo name='DOI' value='10.17487/RFC5234'/>
</reference>



<reference  anchor='RFC6454' target='http://www.rfc-editor.org/info/rfc6454'>
<front>
<title>The Web Origin Concept</title>
<author initials='A.' surname='Barth' fullname='A. Barth'><organization /></author>
<date year='2011' month='December' />
<abstract><t>This document defines the concept of an &quot;origin&quot;, which is often used as the scope of authority or privilege by user agents.  Typically, user agents isolate content retrieved from different origins to prevent malicious web site operators from interfering with the operation of benign web sites.  In addition to outlining the principles that underlie the concept of origin, this document details how to determine the origin of a URI and how to serialize an origin into a string.  It also defines an HTTP header field, named &quot;Origin&quot;, that indicates which origins are associated with an HTTP request.   [STANDARDS-TRACK]</t></abstract>
</front>
<seriesInfo name='RFC' value='6454'/>
<seriesInfo name='DOI' value='10.17487/RFC6454'/>
</reference>



<reference  anchor='RFC6874' target='http://www.rfc-editor.org/info/rfc6874'>
<front>
<title>Representing IPv6 Zone Identifiers in Address Literals and Uniform Resource Identifiers</title>
<author initials='B.' surname='Carpenter' fullname='B. Carpenter'><organization /></author>
<author initials='S.' surname='Cheshire' fullname='S. Cheshire'><organization /></author>
<author initials='R.' surname='Hinden' fullname='R. Hinden'><organization /></author>
<date year='2013' month='February' />
<abstract><t>This document describes how the zone identifier of an IPv6 scoped address, defined as &lt;zone_id&gt; in the IPv6 Scoped Address Architecture (RFC 4007), can be represented in a literal IPv6 address and in a Uniform Resource Identifier that includes such a literal address.  It updates the URI Generic Syntax specification (RFC 3986) accordingly.</t></abstract>
</front>
<seriesInfo name='RFC' value='6874'/>
<seriesInfo name='DOI' value='10.17487/RFC6874'/>
</reference>


<reference anchor="STD63" target="http://www.rfc-editor.org/info/std63">
  <front>
    <title>UTF-8, a transformation format of ISO 10646</title>
    <author initials="F." surname="Yergeau" fullname="F. Yergeau">
      <organization></organization>
    </author>
    <date year="2003" month="November"/>
  </front>
  <seriesInfo name="STD" value="63"/>
  <seriesInfo name="RFC" value="3629"/>
  <seriesInfo name="DOI" value="10.17487/RFC3629"/>
</reference>


    </references>

    <references title='Informative References'>

<reference anchor="BCP35" target="http://www.rfc-editor.org/info/bcp35">
  <front>
    <title>Guidelines and Registration Procedures for URI Schemes</title>
    <author initials="D." surname="Thaler" fullname="D. Thaler" role="editor">
      <organization></organization>
    </author>
    <author initials="T." surname="Hansen" fullname="T. Hansen">
      <organization></organization>
    </author>
    <author initials="T." surname="Hardie" fullname="T. Hardie">
      <organization></organization>
    </author>
    <date year="2015" month="June"/>
  </front>
  <seriesInfo name="BCP" value="35"/>
  <seriesInfo name="RFC" value="7595"/>
  <seriesInfo name="DOI" value="10.17487/RFC7595"/>
</reference>




<reference  anchor='RFC1630' target='http://www.rfc-editor.org/info/rfc1630'>
<front>
<title>Universal Resource Identifiers in WWW: A Unifying Syntax for the Expression of Names and Addresses of Objects on the Network as used in the World-Wide Web</title>
<author initials='T.' surname='Berners-Lee' fullname='T. Berners-Lee'><organization /></author>
<date year='1994' month='June' />
<abstract><t>This document defines the syntax used by the World-Wide Web initiative to encode the names and addresses of objects on the Internet.  This memo provides information for the Internet community.  This memo does not specify an Internet standard of any kind.</t></abstract>
</front>
<seriesInfo name='RFC' value='1630'/>
<seriesInfo name='DOI' value='10.17487/RFC1630'/>
</reference>



<reference  anchor='RFC1738' target='http://www.rfc-editor.org/info/rfc1738'>
<front>
<title>Uniform Resource Locators (URL)</title>
<author initials='T.' surname='Berners-Lee' fullname='T. Berners-Lee'><organization /></author>
<author initials='L.' surname='Masinter' fullname='L. Masinter'><organization /></author>
<author initials='M.' surname='McCahill' fullname='M. McCahill'><organization /></author>
<date year='1994' month='December' />
<abstract><t>This document specifies a Uniform Resource Locator (URL), the syntax and semantics of formalized information for location and access of resources via the Internet. [STANDARDS-TRACK]</t></abstract>
</front>
<seriesInfo name='RFC' value='1738'/>
<seriesInfo name='DOI' value='10.17487/RFC1738'/>
</reference>



<reference  anchor='RFC2396' target='http://www.rfc-editor.org/info/rfc2396'>
<front>
<title>Uniform Resource Identifiers (URI): Generic Syntax</title>
<author initials='T.' surname='Berners-Lee' fullname='T. Berners-Lee'><organization /></author>
<author initials='R.' surname='Fielding' fullname='R. Fielding'><organization /></author>
<author initials='L.' surname='Masinter' fullname='L. Masinter'><organization /></author>
<date year='1998' month='August' />
<abstract><t>This document defines a grammar that is a superset of all valid URI, such that an implementation can parse the common components of a URI reference without knowing the scheme-specific requirements of every possible identifier type.  [STANDARDS-TRACK]</t></abstract>
</front>
<seriesInfo name='RFC' value='2396'/>
<seriesInfo name='DOI' value='10.17487/RFC2396'/>
</reference>



<reference  anchor='RFC6838' target='http://www.rfc-editor.org/info/rfc6838'>
<front>
<title>Media Type Specifications and Registration Procedures</title>
<author initials='N.' surname='Freed' fullname='N. Freed'><organization /></author>
<author initials='J.' surname='Klensin' fullname='J. Klensin'><organization /></author>
<author initials='T.' surname='Hansen' fullname='T. Hansen'><organization /></author>
<date year='2013' month='January' />
<abstract><t>This document defines procedures for the specification and registration of media types for use in HTTP, MIME, and other Internet protocols.  This memo documents an Internet Best Current Practice.</t></abstract>
</front>
<seriesInfo name='BCP' value='13'/>
<seriesInfo name='RFC' value='6838'/>
<seriesInfo name='DOI' value='10.17487/RFC6838'/>
</reference>


<reference anchor="Bash-Tilde" target="http://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html">
  <front>
    <title>Bash Reference Manual: Tilde Expansion</title>
    <author >
      <organization>Free Software Foundation, Inc</organization>
    </author>
    <date year="2014" month="February" day="02"/>
  </front>
</reference>
<reference anchor="WHATWG-URL" target="http://url.spec.whatwg.org/">
  <front>
    <title>URL Living Standard</title>
    <author >
      <organization>WHATWG</organization>
    </author>
    <date year="2013" month="May"/>
  </front>
</reference>
<reference anchor="MS-DTYP" target="http://msdn.microsoft.com/en-us/library/gg465305.aspx">
  <front>
    <title>Windows Data Types, 2.2.57 UNC</title>
    <author >
      <organization>Microsoft Open Specifications</organization>
    </author>
    <date year="2015" month="October" day="16"/>
  </front>
</reference>
<reference anchor="POSIX" >
  <front>
    <title>IEEE Std 1003.1, 2013 Edition</title>
    <author >
      <organization>IEEE</organization>
    </author>
    <date year="2013"/>
  </front>
</reference>
<reference anchor="UAX15" target="http://www.unicode.org/reports/tr15/tr15-44.html">
  <front>
    <title>Unicode Standard Annex #15: Unicode Normalization Forms</title>
    <author initials="M." surname="Davis" fullname="Mark Davis" role="editor">
      <organization></organization>
    </author>
    <author initials="K." surname="Whistler" fullname="Ken Whistler" role="editor">
      <organization></organization>
    </author>
    <date year="2016" month="February" day="24"/>
  </front>
</reference>
<reference anchor="UNICODE" target="http://www.unicode.org/versions/Unicode9.0.0/">
  <front>
    <title>The Unicode Standard, Version 9.0.0</title>
    <author >
      <organization>The Unicode Consortium</organization>
    </author>
    <date year="2016" month="June" day="21"/>
  </front>
  <seriesInfo name="ISBN" value="978-1-936213-13-9"/>
</reference>
<reference anchor="Win32-Namespaces" target="https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx">
  <front>
    <title>Naming Files, Paths, and Namespaces</title>
    <author >
      <organization>Microsoft Developer Network</organization>
    </author>
    <date year="2013" month="June"/>
  </front>
</reference>
<reference anchor="Zsh-Tilde" target="http://zsh.sourceforge.net/Doc/Release/Expansion.html#Filename-Expansion">
  <front>
    <title>zsh: 14.7 Filename Expansion</title>
    <author >
      <organization></organization>
    </author>
    <date year="2015" month="December" day="08"/>
  </front>
</reference>
<reference anchor="Bug107540" target="https://bugzilla.mozilla.org/show_bug.cgi?id=107540">
  <front>
    <title>Bug 107540</title>
    <author >
      <organization>Bugzilla@Mozilla</organization>
    </author>
    <date year="2007" month="October"/>
  </front>
</reference>


    </references>


<section anchor="diff" title="Differences from Previous Specifications">

<t>The syntax definition in <xref target="syntax"/> inherits incremental differences
from the general syntax of <xref target="RFC1738"/> made by <xref target="RFC2396"/>
(<xref target="RFC2396"/>, Appendix G) and <xref target="RFC3986"/> (<xref target="RFC3986"/>, Appendix D).</t>

<t>According to the definition in <xref target="RFC1738"/> a file URL always started
with the token “file://”, followed by an (optionally blank) host name
and a “/”.  The syntax given in <xref target="syntax"/> makes the entire authority
component, including the double slashes “//”, optional.</t>

</section>
<section anchor="examples" title="Example URIs">

<t>The syntax in <xref target="syntax"/> is intended to support file URIs that take the
following forms:</t>

<t>Local files:</t>

<t><list style="symbols">
  <t>A traditional file URI for a local file, with an empty authority.
This is the most common format in use today. E.g.:  <list style="symbols">
      <t><spanx style="verb">file:///path/to/file</spanx></t>
    </list></t>
  <t>The minimal representation of a local file, with no authority field
and an absolute path that begins with a slash “/”. E.g.:  <list style="symbols">
      <t><spanx style="verb">file:/path/to/file</spanx></t>
    </list></t>
</list></t>

<t>Non-local files:</t>

<t><list style="symbols">
  <t>A non-local file, with an explicit authority. E.g.:  <list style="symbols">
      <t><spanx style="verb">file://host.example.com/path/to/file</spanx></t>
    </list></t>
</list></t>

</section>
<section anchor="similar-technologies" title="Similar Technologies">

<t><list style="symbols">
  <t>The WHATWG defines a living URL standard <xref target="WHATWG-URL"/>, which
includes algorithms for interpreting file URIs (as URLs).</t>
  <t>The Universal Naming Convention (UNC) <xref target="MS-DTYP"/> defines a string
format that can perform a similar role to the file URI scheme in
describing the location of files, except that files located by UNC
filespace selector strings are typically stored on a remote machine
and accessed using a network protocol.  <xref target="ext-unc"/> lists some ways
in which UNC filespace selector strings are currently made to
interoperate with the file URI scheme.</t>
  <t>The Microsoft Windows API defines Win32 Namespaces
<xref target="Win32-Namespaces"/> for interacting with files and devices using
Windows API functions.  These namespaced paths are prefixed by
“\\?\” for Win32 File Namespaces and “\\.\” for Win32 Device
Namespaces.  There is also a special case for UNC file paths in Win32
File Namespaces, referred to as “Long UNC”, using the prefix
“\\?\UNC\”.  This specification does not define a mechanism for
translating namespaced paths to or from file URIs.</t>
</list></t>

</section>
<section anchor="system-specific" title="System-Specific Operations">

<t>This appendix is not normative.  It highlights some observed
behaviours and provides system-specific guidance for interacting
with file URIs and paths.  This is not an exhaustive list of operating
or file systems;  rather it is intended to illustrate certain types
of interactions that might be encountered.</t>

<section anchor="sys-unix" title="POSIX Systems">

<t>In a POSIX file system the root of the file system is represented as a
directory with a zero-length name, usually written as “/”;  the
presence of this root in a file URI can be taken as given by the
initial slash in the <spanx style="verb">path-absolute</spanx> rule.</t>

<t>Common UNIX shells such as the Bourne-Again SHell (bash) and Z Shell
(zsh) provide a function known as “tilde expansion” <xref target="Bash-Tilde"/> or
“filename expansion” <xref target="Zsh-Tilde"/>, where a path that begins with a
tilde character “~” can be expanded out to a special directory name.
No such facility exists using the file URI scheme;  a tilde in a file
URI is always just a tilde.</t>

</section>
<section anchor="sys-dos" title="DOS- and Windows-Like Systems">

<t>When mapping a DOS- or Windows-like file path to a file URI, the drive
letter (e.g. “c:”) is typically mapped into the first path segment.</t>

<t><xref target="nonstandard-syntax"/> lists some nonstandard techniques for
interacting with DOS- or Windows-like file paths and URIs.</t>

</section>
<section anchor="sys-osx" title="Mac OS X Systems">

<t>The HFS+ file system uses a nonstandard normalization form, similar
to Normalization Form D <xref target="UAX15"/>.  Take care when transforming HFS+
file paths to and from URIs (<xref target="encoding"/>).</t>

</section>
<section anchor="sys-vms" title="OpenVMS Files-11 Systems">

<t>When mapping a VMS file path to a file URI, the device name is mapped
into the first path segment.  Note that the dollars sign “$” is
a reserved character per the definition in <xref target="RFC3986"/>, Section 2.2,
so should be percent-encoded if present in the device name.</t>

<t>If the VMS file path includes a node reference, that reference is used
as the authority.  Where the original node reference includes a user
name and password in an access control string, they can be transcribed
into the authority using the nonstandard syntax extension in
<xref target="ext-userinfo"/>.</t>

</section>
</section>
<section anchor="nonstandard-syntax" title="Nonstandard Syntax Variations">

<t>These variations may be encountered by existing usages of the file URI
scheme, but are not supported by the normative syntax of <xref target="syntax"/>.</t>

<t>This appendix is not normative.</t>

<section anchor="ext-userinfo" title="User Information">

<t>It might be necessary to include user information such as a user name in
a file URI, for example when mapping a VMS file path with a node
reference that includes an access control string.</t>

<t>To allow user information to be included in a file URI, the <spanx style="verb">file-auth</spanx>
rule in <xref target="syntax"/> can be replaced with the following:</t>

<figure><artwork><![CDATA[
   file-auth      = "localhost"
                  / [ userinfo "@" ] host
]]></artwork></figure>

<t>This uses the <spanx style="verb">userinfo</spanx> rule from <xref target="RFC3986"/>.</t>

<t>As discussed in the HP OpenVMS Systems Documentation
&lt;http://h71000.www7.hp.com/doc/84final/ba554_90015/ch03s09.html&gt;
“access control strings include sufficient information to allow someone
to break in to the remote account, [therefore] they create serious
security exposure.”  In a similar vein, the presence of a password in a
“user:password” userinfo field is deprecated by <xref target="RFC3986"/>.  Take care
when dealing with information that can be used to identify a user or
grant access to a system.</t>

</section>
<section anchor="ext-drives" title="DOS and Windows Drive Letters">

<t>On Windows- or DOS-like file systems an absolute file path can begin
with a drive letter.  To facilitate this, the <spanx style="verb">local-path</spanx> rule in
<xref target="syntax"/> can be replaced with the following:</t>

<figure><artwork><![CDATA[
   local-path     = [ drive-letter ] path-absolute

   drive-letter   = ALPHA ":"
]]></artwork></figure>

<t>The <spanx style="verb">ALPHA</spanx> rule is defined in <xref target="RFC5234"/>.</t>

<t>This is intended to support the minimal representation of a local file
in a DOS- or Windows-like environment, with no authority field and an
absolute path that begins with a drive letter.  E.g.:</t>

<t><list style="symbols">
  <t><spanx style="verb">file:c:/path/to/file</spanx></t>
</list></t>

<t>URIs of the form <spanx style="verb">file:///c:/path/to/file</spanx> are already supported by the
<spanx style="verb">path-absolute</spanx> rule.</t>

<t>Note that comparison of drive letters in DOS or Windows file paths
is case-insensitive.  In some usages of file URIs drive letters are
canonicalized by converting them to uppercase, and other usages treat
URIs that differ only in the case of the drive letter as identical.</t>

<section anchor="ext-relative" title="Relative Resolution">

<t>To mimic the behaviour of DOS- or Windows-like file systems, relative
references beginning with a slash “/” can be resolved relative to the
drive letter, when present;  and resolution of “..” dot segments (per
Section 5.2.4 of <xref target="RFC3986"/>) can be modified to not ever overwrite the
drive letter.</t>

<t>For example:</t>

<figure><artwork><![CDATA[
   base URI:   file:///c:/path/to/file.txt
   rel. ref.:  /some/other/thing.bmp
   resolved:   file:///c:/some/other/thing.bmp

   base URI:   file:///c:/foo.txt
   rel. ref.:  ../bar.txt
   resolved:   file:///c:/bar.txt
]]></artwork></figure>

<t>A relative reference starting with a drive letter would be interpreted
by a generic URI parser as a URI with the drive letter as its scheme.
Instead such a reference ought to be constructed with a leading slash
“/” character (e.g. “/c:/foo.txt”).</t>

<t>Relative references with a drive letter followed by a character other
than a slash (e.g. “/c:bar/baz.txt” or “/c:../foo.txt”) might not be
accepted as dereferenceable URIs in DOS- or Windows-like systems.</t>

</section>
<section anchor="ext-pipe" title="Vertical Line Character">

<t>Historically some usages of file URIs have included a vertical line
character “|” instead of a colon “:” in the drive letter construct.
<xref target="RFC3986"/> forbids the use of the vertical line, however it may be
necessary to interpret or update old URIs.</t>

<t>For interpreting such URIs, the <spanx style="verb">auth-path</spanx> and <spanx style="verb">local-path</spanx> rules in
<xref target="syntax"/> and the <spanx style="verb">drive-letter</spanx> rule above can be replaced with the
following:</t>

<figure><artwork><![CDATA[
   auth-path      = [ file-auth ] path-absolute
                  / [ file-auth ] file-absolute

   local-path     = [ drive-letter ] path-absolute
                  / file-absolute

   file-absolute  = "/" drive-letter path-absolute

   drive-letter   = ALPHA ":"
                  / ALPHA "|"
]]></artwork></figure>

<t>This is intended to support regular DOS or Windows file URIs with
vertical line characters in the drive letter construct.  E.g.:</t>

<t><list style="symbols">
  <t><spanx style="verb">file:///c|/path/to/file</spanx></t>
  <t><spanx style="verb">file:/c|/path/to/file</spanx></t>
  <t><spanx style="verb">file:c|/path/to/file</spanx></t>
</list></t>

<t>To update such an old URI, replace the vertical line “|” with a
colon “:”.</t>

</section>
</section>
<section anchor="ext-unc" title="UNC Strings">

<t>Some usages of the file URI scheme allow UNC filespace selector strings
<xref target="MS-DTYP"/> to be translated to and from file URIs, either by mapping
the equivalent segments of the two schemes (hostname to authority,
sharename+objectnames to path), or by mapping the entire UNC string to
the path segment of a URI.</t>

<section anchor="ext-unc-map" title="file URI with Authority">

<t>The following is an algorithmic description of the process of
translating a UNC filespace selector string to a file URI by
mapping the equivalent segments of the two schemes:</t>

<t><list style="numbers">
  <t>Initialize the URI with the “file:” scheme identifier.</t>
  <t>Append the authority:  <list style="numbers">
      <t>Append the “//” authority sigil to the URI.</t>
      <t>Append the host-name field of the UNC string to the URI.</t>
    </list></t>
  <t>Append the share-name:  <list style="numbers">
      <t>Transform the share-name to a path segment (<xref target="RFC3986"/>,
Section 3.3) to conform to the encoding rules of Section 2 of
<xref target="RFC3986"/>.</t>
      <t>Append a delimiting slash character “/” and the transformed
segment to the URI.</t>
    </list></t>
  <t>For each object-name:  <list style="numbers">
      <t>Transform the objectname to a path segment as above.      <vspace blankLines='1'/>
The colon character “:” is allowed as a delimiter before
stream-name and stream-type in the file-name, if present.</t>
      <t>Append a delimiting slash character “/” and the transformed
segment to the URI.</t>
    </list></t>
</list></t>

<t>For example:</t>

<figure><artwork><![CDATA[
   UNC String:   \\host.example.com\Share\path\to\file.txt
   URI:          file://host.example.com/Share/path/to/file.txt
]]></artwork></figure>

<t>The inverse algorithm, for translating a file URI to a UNC filespace
selector string, is left as an exercise for the reader.</t>

</section>
<section anchor="ext-unc-path" title="file URI with UNC Path">

<t>It is common to encounter file URIs that encode entire UNC strings in
the path, usually with all backslash “\” characters replaced with
slashes “/”.</t>

<t>To interpret such URIs, the <spanx style="verb">auth-path</spanx> rule in <xref target="syntax"/> can be
replaced with the following:</t>

<figure><artwork><![CDATA[
   auth-path      = [ file-auth ] path-absolute
                  / unc-authority path-absolute

   unc-authority  = 2*3"/" file-host

   file-host      = inline-IP / IPv4address / reg-name

   inline-IP      = "%5B" ( IPv6address / IPvFuture ) "%5D"
]]></artwork></figure>

<t>This syntax uses the <spanx style="verb">IPv4address</spanx>, <spanx style="verb">IPv6address</spanx>, <spanx style="verb">IPvFuture</spanx>,
and <spanx style="verb">reg-name</spanx> rules from <xref target="RFC3986"/>.</t>

<t><list style='empty'>
  <t>Note that the <spanx style="verb">file-host</spanx> rule is the same as <spanx style="verb">host</spanx> but with
percent-encoding applied to “[” and “]” characters.</t>
</list></t>

<t>This extended syntax is intended to support URIs that take the
following forms, in addition to those in <xref target="examples"/>:</t>

<t>Non-local files:</t>

<t><list style="symbols">
  <t>The representation of a non-local file, with an empty authority and a
complete (transformed) UNC string in the path.  E.g.:  <list style="symbols">
      <t><spanx style="verb">file:////host.example.com/path/to/file</spanx></t>
    </list></t>
  <t>As above, with an extra slash between the empty authority and the
transformed UNC string, as per the syntax defined in <xref target="RFC1738"/>.
E.g.:  <list style="symbols">
      <t><spanx style="verb">file://///host.example.com/path/to/file</spanx></t>
    </list>
This representation is notably used by the Firefox web browser.
See Bugzilla#107540 <xref target="Bug107540"></xref>.</t>
</list></t>

<t>It also further limits the definition of a “local file URI” by
excluding any file URI with a path that encodes a UNC string.</t>

</section>
</section>
<section anchor="ext-backslash" title="Backslash as Separator">

<t>Historically some usages have copied entire file paths into the path
components of file URIs.  Where DOS or Windows file paths were thus
copied the resulting URI strings contained unencoded backslash “\”
characters, which are forbidden by both <xref target="RFC1738"/> and <xref target="RFC3986"/>.</t>

<t>It may be possible to translate or update such an invalid file URI by
replacing all backslashes “\” with slashes “/”, if it can be
determined with reasonable certainty that the backslashes are intended
as path separators.</t>

</section>
</section>
<section anchor="collected" title="Collected Nonstandard Rules">

<t>Here are the collected syntax rules for all optional appendices,
presented for convenience.  This collected syntax is not normative.</t>

<figure><artwork><![CDATA[
   file-URI       = file-scheme ":" file-hier-part

   file-scheme    = "file"

   file-hier-part = ( "//" auth-path )
                  / local-path

   auth-path      = [ file-auth ] path-absolute
                  / [ file-auth ] file-absolute
                  / unc-authority path-absolute

   local-path     = [ drive-letter ] path-absolute
                  / file-absolute

   file-auth      = "localhost"
                  / [ userinfo "@" ] host

   unc-authority  = 2*3"/" file-host

   file-host      = inline-IP / IPv4address / reg-name

   inline-IP      = "%5B" ( IPv6address / IPvFuture ) "%5D"

   file-absolute  = "/" drive-letter path-absolute

   drive-letter   = ALPHA ":"
                  / ALPHA "|"
]]></artwork></figure>

<t>This collected syntax is intended to support file URIs that take the
following forms:</t>

<t>Local files:</t>

<t><list style="symbols">
  <t>A traditional file URI for a local file, with an empty authority.
E.g.:  <list style="symbols">
      <t><spanx style="verb">file:///path/to/file</spanx></t>
    </list></t>
  <t>The minimal representation of a local file, with no authority
field and an absolute path that begins with a slash “/”.  E.g.:  <list style="symbols">
      <t><spanx style="verb">file:/path/to/file</spanx></t>
    </list></t>
  <t>The minimal representation of a local file in a DOS- or
Windows-based environment, with no authority field and an
absolute path that begins with a drive letter.  E.g.:  <list style="symbols">
      <t><spanx style="verb">file:c:/path/to/file</spanx></t>
    </list></t>
  <t>Regular DOS or Windows file URIs, with vertical line characters
in the drive letter construct.  E.g.:  <list style="symbols">
      <t><spanx style="verb">file:///c|/path/to/file</spanx></t>
      <t><spanx style="verb">file:/c|/path/to/file</spanx></t>
      <t><spanx style="verb">file:c|/path/to/file</spanx></t>
    </list></t>
</list></t>

<t>Non-local files:</t>

<t><list style="symbols">
  <t>The representation of a non-local file, with an explicit authority.
E.g.:  <list style="symbols">
      <t><spanx style="verb">file://host.example.com/path/to/file</spanx></t>
    </list></t>
  <t>The “traditional” representation of a non-local file, with an
empty authority and a complete (transformed) UNC string in the
path.  E.g.:  <list style="symbols">
      <t><spanx style="verb">file:////host.example.com/path/to/file</spanx></t>
    </list></t>
  <t>As above, with an extra slash between the empty authority and the
transformed UNC string.  E.g.:  <list style="symbols">
      <t><spanx style="verb">file://///host.example.com/path/to/file</spanx></t>
    </list></t>
</list></t>

</section>


  </back>


</rfc>

