<?xml version="1.0" encoding="US-ASCII"?>
  <?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 compact="yes"?>
<?rfc subcompact="no"?>

<rfc number="8089"
     ipr="trust200902" 
     submissionType="IETF"
     consensus="yes"
     category="std" 
     updates="1738">

  <front>
    <title abbrev="&quot;file Scheme&quot;">The &quot;file&quot; 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 month="February" year="2017"/>

    <area>General</area>
    <workgroup>Applications Area Working Group</workgroup>

    <keyword>uniform resource identifier</keyword>
    <keyword>URL</keyword>

    <abstract>

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

<t>It defines a common syntax that 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>

  </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 that 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 that 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 postdates 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" that 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"/>, which lists some nonstandard syntax
variations that can be encountered in practice.</t>

</section>
<section anchor="operations" title="Operations Involving &lt;file&gt; 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
Section 2.5 of <xref target="RFC3986"/>).</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 not be possible for this
specification to list all such significant characters and device names.
Implementers should research the reserved names and characters for the
types of storage devices 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 permanent URI scheme. The "Uniform
Resource Identifier (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'/>
  IETF &lt;ietf@ietf.org&gt;</t>
  <t hangText='References:'><vspace blankLines='0'/>
  This RFC</t>
</list></t>

</section>

  </middle>

  <back>

    <references title='Normative References'>

<?rfc include="reference.RFC.2119.xml"?>

<?rfc include="reference.RFC.3986.xml"?>

<?rfc include="reference.RFC.5234.xml"?>

<?rfc include="reference.RFC.6454.xml"?>

<?rfc include="reference.RFC.6874.xml"?>

<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 /></author>
<date year='2003' month='November' />
<abstract><t>ISO/IEC 10646-1 defines a large character set called the Universal Character Set (UCS) which encompasses most of the world's writing systems.  The originally proposed encodings of the UCS, however, were not compatible with many current applications and protocols, and this has led to the development of UTF-8, the object of this memo.  UTF-8 has the characteristic of preserving the full US-ASCII range, providing compatibility with file systems, parsers and other software that rely on US-ASCII values but are transparent to other values.  This memo obsoletes and replaces RFC 2279.</t></abstract>
</front>
<seriesInfo name='STD' value='63'/>
<seriesInfo name='RFC' value='3629'/>
</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 /></author>
<author initials='T.' surname='Hansen' fullname='T. Hansen'><organization /></author>
<author initials='T.' surname='Hardie' fullname='T. Hardie'><organization /></author>
<date year='2015' month='June' />
<abstract><t>This document updates the guidelines and recommendations, as well as the IANA registration processes, for the definition of Uniform Resource Identifier (URI) schemes.  It obsoletes RFC 4395.</t></abstract>
</front>
<seriesInfo name='BCP' value='35'/>
<seriesInfo name='RFC' value='7595'/>
</reference>


<?rfc include="reference.RFC.1630.xml"?>

<?rfc include="reference.RFC.1738.xml"?>

<?rfc include="reference.RFC.2396.xml"?>

<?rfc include="reference.RFC.6838.xml"?>

<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="2016" month="September"/>
  </front>
</reference>

<reference anchor="WHATWG-URL" target="https://url.spec.whatwg.org/">
  <front>
    <title>URL Living Standard</title>
    <author >
      <organization>WHATWG</organization>
    </author>
    <date year="2017" month="January"/>
  </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</organization>
    </author>
    <date year="2015" month="October"/>
  </front>
</reference>

<reference anchor="POSIX" >
  <front>
    <title>IEEE Std 1003.1, 2013 Edition - Standard for Information
    Technology-- Portable Operating System Interface (POSIX(R)) Base
    Specifications, Issue 7</title>
    <author >
      <organization>IEEE</organization>
    </author>
    <date month="April" year="2013"/>
  </front>
  <seriesInfo name="DOI" value="10.1109/IEEESTD.2013.6506091" />
</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"/>
  </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"/>
  </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 Blogs</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>The Z Shell Manual: 14.7 Filename Expansion</title>
    <author >
      <organization></organization>
    </author>
    <date year="2015" month="December"/>
  </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="2001" 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"/>, as described by
Appendix G of <xref target="RFC2396"/> and Appendix D of <xref target="RFC3986"/>.</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. For example:  <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 "/". For example:  <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. For example:  <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 URL specification <xref target="WHATWG-URL"/> defines browser behavior
for a variety of inputs, including file URIs.  As a living document,
it changes to reflect updates in browser behavior.  As a result, its
algorithms and syntax definitions may or may not be consistent with
this specification.  Implementors should be aware of this possible
discrepancy if they expect to share file URIs with browsers that
follow the WHATWG specification.</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
behaviors 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 Hierarchical File System Plus (HFS+) 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 Virtual Memory System (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 Section 2.2 of <xref target="RFC3986"/>,
so it 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.  For example:</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; 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 behavior of DOS- or Windows-like file systems, relative
references beginning with a slash "/" can be resolved relative to the
drive letter when present; 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.  For example:</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="&lt;file&gt; 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 (see Section 3.3 of <xref
      target="RFC3986"/>) 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, the UNC String:</t>

<figure><artwork><![CDATA[
   UNC String:   \\host.example.com\Share\path\to\file.txt
]]></artwork></figure>
<t>would be transformed into the URI:</t>
<figure><artwork><![CDATA[
   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="&lt;file&gt; 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.  For example:  <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"/>.
For example:  <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.
For example:  <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 "/".  For example:  <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.  For example:  <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.  For example:  <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.
For example:  <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.  For example:  <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.  For example:  <list style="symbols">
      <t><spanx style="verb">file://///host.example.com/path/to/file</spanx></t>
    </list></t>
</list></t>

</section>

<section anchor="acknowledgements" title="Acknowledgements" numbered="no">
<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 IEBlog 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>
  </back>


</rfc>
