Applications Area Working Group | M. Kerwin |
Internet-Draft | QUT |
Obsoletes: 1738 (if approved) | January 11, 2015 |
Intended status: Standards Track | |
Expires: July 15, 2015 |
The file URI Scheme
draft-ietf-appsawg-file-scheme-00
This document specifies the “file” Uniform Resource Identifier (URI) scheme, replacing the definition in RFC 1738.
It attempts to document current practices, while at the same time defining a common core which is intended to interoperate across the broad spectrum of existing implementations.
Note to Readers (To be removed by the RFC Editor)
This draft should be discussed on the IETF Applications Area Working Group discussion list apps-discuss@ietf.org.
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."
This Internet-Draft will expire on July 15, 2015.
Copyright (c) 2015 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
A file URI identifies a file on a particular file system. It can be used in discussions about the file, and if other conditions are met it can be dereferenced to directly access the file.
The file URI scheme is not coupled with a specific protocol. As such, there is no well-defined set of methods that can be performed on file URIs, nor a media type associated with them.
This document defines a syntax that is compatible with most extant implementations, while attempting to push towards a stricter subset of “ideal” constructs. In many cases it simultaneously acknowledges and deprecates some less common or outdated constructs.
The file URI scheme was first defined in [RFC1630], which, being an informational RFC, does not specify an Internet standard. The definition was standardised in [RFC1738], and the scheme was registered with the Internet Assigned Numbers Authority (IANA); however that definition omitted certain language included by former that clarified aspects such as:
The Internet draft [I-D.draft-hoffman-file-uri] was written in an effort to keep the file URI scheme on standards track when [RFC1738] was made obsolete, but that draft expired in 2005. It enumerated concerns arising from the various, often conflicting implementations of the scheme. It serves as the spiritual predecessor of this document.
Additionally the WHATWG defines a living URL standard [WHATWG-URL], which includes algorithms for interpreting file URIs (as URLs).
The Universal Naming Convention (UNC) [MS-DTYP] defines a string format that can perform a similar role to the file URI scheme in describing the location of files. A UNC filespace selector string has three parts: host, share, and path; see: Appendix A. This document describes a means of translating between UNC filespace selector strings and file URIs.
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 [RFC2119].
The file URI syntax is defined here in Augmented Backus-Naur Form (ABNF) [RFC5234], including the core ABNF syntax rule ALPHA defined by that specification, and importing the userinfo, host, path-absolute, and query rules from [RFC3986] (as updated by [RFC6874].)
file-URI = f-scheme ":" f-hier-part [ "?" query ] f-scheme = "file" f-hier-part = "//" auth-path / local-path auth-path = [ f-auth ] path-absolute / unc-path / windows-path f-auth = [ userinfo "@" ] host local-path = path-absolute / windows-path unc-path = 2*3"/" authority path-absolute windows-path = drive-letter path-absolute drive-letter = ALPHA [ drive-marker ] drive-marker = ":" / "|"
Note well: the drive-marker rule intentionally includes a bar character “|” even though that character is not part of either the unreserved or reserved character sets in [RFC3986], and thus would normally have to be percent-encoded to be included in a URI. This specification explicitly supports the parsing of otherwise invalid URIs – those with an unencoded bar character forming part of a DOS or Windows drive letter identifier – to facilitate parsing extant historical URIs, but new URIs of this form MUST NOT be generated.
The query field contains non-hierarchical data that, along with data in the path components (path-absolute, unc-path, or windows-path) serves to identify a resource. This is not commonly used in practice, but could be used to refer to a specific version of a file in a versioning file system, for example.
Systems exhibit different levels of case-sensitivity. Unless the file system is known to be case-insensitive, implementations MUST maintain the case of file and directory names when translating file URIs to and from the local system’s representation of file paths, and any systems or devices that transport file URIs MUST NOT alter the case of file URIs they transport.
The syntax definition above is necessarily different from those given in [RFC1630] and [RFC1738] because it depends on the generic syntax from [RFC3986] that post-dates all previous specifications.
It is intended to support file URIs that take the following forms:
Local files:
Non-local files:
Dubious encodings:
It also intentionally excludes URIs of the form:
In the strictest terms, the only operations that can be performed on a file URI are translating it to and from a file path; subsequent methods are performed on the resulting file path, and depend entirely on the file system’s APIs.
For example, consider the POSIX open(), read(), and close() methods [POSIX] for reading a file’s contents into memory.
Some APIs allow file system methods to be invoked directly on file URIs, while others provide mappings to other similar methods, such as GET and PUT from the Hyptertext Transfer Protocol (HTTP) [RFC7231].
The local file system API can only be used if the file URI has a blank (or absent) authority and the path, when transformed to the local system’s conventions, is not a UNC string. Note that this differs from the definition in [RFC1738] in that previously an authority containing the text “localhost” was used to refer to the local file system, but in this specification it translates to a UNC string referring to the host “localhost”.
This specification does not define a mechanism for accessing files stored on non-local file systems.
Below is an algorithmic description of the process used to convert a file path to an Internationalized Resource Identifier (IRI) [RFC3987], which can then be translated to a URI as per Section 3.1 of [RFC3987]; see: Section 4.
Examples:
File Path | URIs (minimal, traditional) -------------------------------+-------------------------------- UNIX-like: | /path/to/file | file:/path/to/file | file:///path/to/file | /path/to/dir/ | file:/path/to/dir/ | file:///path/to/dir/ | DOS- or Windows-based: | c:\path\to\file.txt | file:c:/path/to/file.txt | file:///c:/path/to/file.txt | c:\path\to\dir\ | file:c:/path/to/dir/ | file:///c:/path/to/dir/ VMS Files-11: | ::DISK1:[PATH.TO]FILE.TXT;2 | file:/DISK1/PATH/TO/FILE.TXT?2 | file:///DISK1/PATH/TO/FILE.TXT?2 |
Differences from RFC 1738
In [RFC1738] a file URL always started with the token “file://”, followed by an authority and a “/”. That “/” was not considered part of the path. This implies that the correct encoding for the above example file path in a UNIX-like environment would have been:
token + authority + slash + path = "file://" + "" + "/" + "/path/to/file.txt" = "file:////path/to/file.txt"
However that construct was never used in practice, and in fact would have collided with the eventual encoding of UNC strings in URIs.
Exceptions
A UNC filespace selector string can be directly translated to an Internationalized Resource Identifier (IRI) [RFC3987], which can then be translated to a URI as per Section 3.1 of [RFC3987]; see: Section 4.
Example:
UNC String: \\host.example.com\Share\path\to\file.txt URI: file://host.example.com/Share/path/to/file.txt
Exceptions
Many implementations accept the full UNC string in the URI path (with all backslashes “\” converted to slashes “/”). Additionally, because [RFC1738] said that the first “/” after “file://[authority]” wasn’t part of the path, some implementations (including Firefox) require an additional slash before the UNC string.
For example:
Traditional: file:////hostname/share/object/names \_____/\__________________________ / Scheme Transformed UNC string Firefox: file://///hostname/share/object/names \_____/|\__________________________ / Scheme | Transformed UNC string Extra slash
Translating a non-local file path other than a UNC string to a file URI follows the same basic algorithm as for local files, above, except that the authority MUST refer to the network-accesible node that hosts the file.
For example, in a clustered OpenVMS Files-11 system the authority would contain the node name. Where the original node reference includes a username and password in an access control string, they MAY be transcribed into the userinfo field of the authority ([RFC3986], Section 3.2.1), security considerations (Section 5) notwithstanding.
Some conventional file path formats are known to be incompatible with the file URI scheme.
The Microsoft Windows API defines Win32 Namespaces [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.
The encoding of a file URI depends on the file system. If the file system uses a known non-Unicode character encoding, the path SHOULD be converted to a sequence of characters from the Universal Character Set [ISO10646] normalized according to Normalization Form C (NFC) [UTR15], before being translated to a file URI, and conversely a file URI SHOULD be converted back to the file system’s native encoding when translating to a file path.
When the file system’s encoding is not known the file URI SHOULD be transported as an Internationalized Resource Identifier (IRI) [RFC3987].
Example: file IRI:
| Bytes of file IRI in a UTF-8 document: | 66 69 6c 65 3a 43 3a 2f 72 65 c3 a7 75 2e 74 78 74 | f i l e : c : / r e ( c ) u . t x t | | Interpretation: | A file named "recu.txt" with a cedilla on the "c", in the | directory "C:\" of a DOS or Windows file system. | | Character value sequences of file paths, for various file system | encodings: | | o UTF-16 (e.g. NTFS): | 0043 003a 005c 0072 0065 00e7 0075 002e 0074 0078 0074 | | o Codepage 437 (e.g. MS-DOS): | 43 3a 5c 72 65 87 75 2e 74 78 74
Counter-example: ambiguous file URI:
| File URI, in any ASCII-compatible document: | "file:///%E3%81%A1" | | Possible interpretations of the file name, depending on the | (unknown) encoding of the file system: | | o UTF-8: | <HIRAGANA LETTER TI (U+3061)> | | o Codepage 437: | <GREEK SMALL LETTER PI (U+03C0)> + | <LATIN SMALL LETTER U WITH DIAERESIS (U+00FC)> + | <LATIN SMALL LETTER I WITH ACUTE (U+00ED)> | | o EBCDIC: | "Ta~" | | o US-ASCII: | "%E3%81%A1" | | etc.
There are many security considerations for URI schemes discussed in [RFC3986].
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. Software using file URIs MUST NOT grant greater access than would be available for other file access methods.
Additionally, as discussed in the HP OpenVMS Systems Documentation http://h71000.www7.hp.com/doc/84final/ba554_90015/ch03s09.html “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 [RFC3986]. As such, the userinfo field of a file URI, if present, MUST NOT contain a password.
IANA maintains the registry of URI Schemes [BCP115] at http://www.iana.org/assignments/uri-schemes/.
This document defines the following URI scheme, so the “Permanent URI Schemes” registry has been updated accordingly.
URI Scheme | Description | Reference |
---|---|---|
file | Host-specific file names | RFC XXXX |
RFC Editor Note: Replace XXXX with this RFC’s reference.
This specification is derived from [RFC1738], [RFC3986], and [I-D.draft-hoffman-file-uri] (expired); the acknowledgements in those documents still apply.
Additional thanks to Dave Risney, author of the informative IE Blog article http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx, and Dave Thaler for their comments and suggestions.
The UNC filespace selector string is a null-terminated sequence of characters from the Universal Character Set [ISO10646].
The syntax of a UNC filespace selector string, as defined by [MS-DTYP], is given here in Augmented Backus-Naur Form (ABNF) [RFC5234] for convenience. Note that this definition is informative only; the normative description is in [MS-DTYP].
UNC = "\\" hostname "\" sharename *( "\" objectname ) hostname = netbios-name / fqdn / ip-address sharename = <name of share or resource to be accessed> objectname = <depends on resource being accessed>
The precise format of sharename depends on the protocol; see: SMB [MS-SMB], NFS [RFC3530], NCP [NOVELL].