Applications Area Working Group M. Kerwin Internet-Draft QUT Obsoletes: 1738 (if approved) January 12, 2015 Intended status: Standards Track Expires: July 16, 2015 The file URI Scheme draft-ietf-appsawg-file-scheme-00 Abstract 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>. Status of This Memo 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 16, 2015. Copyright Notice 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 Kerwin Expires July 16, 2015 [Page 1]
Internet-Draft file-scheme January 2015 (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. Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1.1. History . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2. Similar Technologies . . . . . . . . . . . . . . . . . . 3 1.3. Notational Conventions . . . . . . . . . . . . . . . . . 3 2. Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3. Methods on file URIs . . . . . . . . . . . . . . . . . . . . 7 3.1. Translating Local File Path to file URI . . . . . . . . . 7 3.2. Translating UNC String to file URI . . . . . . . . . . . 10 3.3. Translating Non-local File Path to file URI . . . . . . . 11 3.4. Incompatible File Paths . . . . . . . . . . . . . . . . . 11 3.4.1. Namespaces . . . . . . . . . . . . . . . . . . . . . 11 4. Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . 11 5. Security Considerations . . . . . . . . . . . . . . . . . . . 13 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 13 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 14 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 14 8.1. Normative References . . . . . . . . . . . . . . . . . . 14 8.2. Informative References . . . . . . . . . . . . . . . . . 15 Appendix A. UNC Syntax . . . . . . . . . . . . . . . . . . . . . 16 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 16 1. Introduction 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. Kerwin Expires July 16, 2015 [Page 2]
Internet-Draft file-scheme January 2015 1.1. History 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: o the use of slashes to denote boundaries between directory levels of a hierarchical file system; and o the requirement that client software convert the file URI into a file name in the local file name conventions. 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). 1.2. Similar Technologies 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. 1.3. Notational Conventions 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]. 2. Syntax 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].) Kerwin Expires July 16, 2015 [Page 3]
Internet-Draft file-scheme January 2015 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. Kerwin Expires July 16, 2015 [Page 4]
Internet-Draft file-scheme January 2015 It is intended to support file URIs that take the following forms: Local files: o "file:///path/to/file" A "traditional" file URI for a local file, with an empty authority. This is the most common format in use today, despite being technically incompatible with the definition in [RFC1738]. o "file:///c:/path/to/file" The traditional representation of a local file in a DOS- or Windows-based environment. o "file:/path/to/file" A "modern" minimal representation of a local file in a UNIX- like environment, with no authority field and an absolute path that begins with a slash "/". o "file:c:/path/to/file" 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. o "file:///c/path/to/file" o "file:/c/path/to/file" o "file:c/path/to/file" Representations of a local file in a DOS- or Windows-based environment, using alternative representations of drive letters. These are supported for compatibility with historical implementationsm, but deprecated by this specification. o "file:/c:/path/to/file" A representation of a local file in a DOS- or Windows-based environment, with no authority field and a slash preceding the drive letter. This representation is less common than those above, and is deprecated by this specification. Kerwin Expires July 16, 2015 [Page 5]
Internet-Draft file-scheme January 2015 Non-local files: o "file://host.example.com/path/to/file" The ideal representation of a non-local file, with an explicit authority. o "file:////host.example.com/path/to/file" The "traditional" representation of a non-local file, with an empty authority and a complete (transformed) UNC string in the path. o "file://///host.example.com/path/to/file" As above, with an extra slash between the empty authority and the transformed UNC string, conformant with the definition from [RFC1738]; see: exceptions in Section 3.2. This representation is deprecated by this specification. It is notably used by the Firefox web browser. Dubious encodings: o "file://c:/path/to/file" o "file://c/path/to/file" An encoding that includes a Windows drive letter as the authority field. This encoding exists in some extant implementations, and is supported by the grammar for historical reasons. New URIs of this form SHOULD NOT be generated. o "file:///c|/path/to/file" o "file://c|/path/to/file" o "file:/c|/path/to/file" o "file:c|/path/to/file" Various generally invalid URIs that include a disallowed bar character "|" in the drive letter identifier. These encodings are supported by the grammar for historical reasons. As noted above, new URIs of this form MUST NOT be generated. It also intentionally excludes URIs of the form: o "file://auth.example.com//host.example.com/path/to/file" Kerwin Expires July 16, 2015 [Page 6]
Internet-Draft file-scheme January 2015 An encoding that includes both a non-local authority, and a UNC string. The traditional implication was that the shared object described by the UNC string may only be accessed from the machine "auth.example.com". 3. Methods on file URIs 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. 3.1. Translating Local File Path to file URI 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. 1. Resolve the file path to its fully qualified absolute form. 2. Initialise the URI with the "file:" scheme identifier. 3. If including an empty authority field, append the "//" sigil to the URI. Kerwin Expires July 16, 2015 [Page 7]
Internet-Draft file-scheme January 2015 4. Append the root directory: * On a DOS- or Windows-based system, assign the drive letter (e.g. "c:") as the first path segment, and append it to the URI, followed by a slash character "/". + If an empty authority was included at step 3, a slash "/" is prepended to the drive letter (e.g. "/c:") to distinguish it from the authority. * On an OpenVMS Files-11 system, append a slash "/" to the URI, and encode the device name as the first segment as per step 5, below, except that the dollars sign character "$" is not treated as a reserved character in this segment. * On a UNIX-like system, append a slash "/" to the URI, to denote the root directory. 5. For each directory in the path after the root: 1. Transform the directory name to a path segment ([RFC3986], Section 3.3) as per Section 2 of [RFC3986]. 2. Append the transformed segment and a delimiting slash character "/" to the URI. 6. If the path includes a file name: 1. Transform the file name to a path segment as above. 2. Append the transformed segment to the URI. 7. If any non-hierarchical data is required to identify the file (for example a version number in a versioning file system): 1. Append a question mark character "?" to the URI. 2. Transform the non-hierarchical data to a query field ([RFC3986], Section 3.4) as per Section 2 of [RFC3986]. 3. Append the transformed query field to the URI. Kerwin Expires July 16, 2015 [Page 8]
Internet-Draft file-scheme January 2015 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 DOS/Windows: Some implementations leave the leading slash off before the drive letter when authority is blank, e.g. "file://c:/..." DOS/Windows: Some implementations replace ":" with "|", and others leave it off completely. e.g. "file:///c|/..." or "file:///c/..." Kerwin Expires July 16, 2015 [Page 9]
Internet-Draft file-scheme January 2015 3.2. Translating UNC String to file URI 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. 1. Initialise the URI with the "file:" scheme identifier. 2. Append the authority: 1. Append the "//" authority sigil to the URI. 2. Append the hostname field of the UNC string to the URI. 3. Append the sharename: 1. Transform the sharename to a path segment ([RFC3986], Section 3.3) as per Section 2 of [RFC3986]. 2. Append a delimiting slash character "/" and the transformed segment to the URI. 4. For each objectname: 1. Transform the objectname to a path segment ([RFC3986], Section 3.3) as per Section 2 of [RFC3986]. 2. Append a delimiting slash character "/" and the transformed segment to the URI. 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. Kerwin Expires July 16, 2015 [Page 10]
Internet-Draft file-scheme January 2015 For example: Traditional: file:////hostname/share/object/names \_____/\__________________________ / Scheme Transformed UNC string Firefox: file://///hostname/share/object/names \_____/|\__________________________ / Scheme | Transformed UNC string Extra slash 3.3. Translating Non-local File Path to file URI 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. 3.4. Incompatible File Paths Some conventional file path formats are known to be incompatible with the file URI scheme. 3.4.1. Namespaces 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. 4. Encoding 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 Kerwin Expires July 16, 2015 [Page 11]
Internet-Draft file-scheme January 2015 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. Note that many modern file systems encode directory and file names as arbitrary sequences of octets. In those cases, the representation as an encoded string often depends on the user's localization settings, or defaults to UTF-8 [STD63]. 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)> | Kerwin Expires July 16, 2015 [Page 12]
Internet-Draft file-scheme January 2015 | | 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. 5. Security Considerations 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. 6. IANA Considerations 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. Kerwin Expires July 16, 2015 [Page 13]
Internet-Draft file-scheme January 2015 7. Acknowledgements 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. 8. References 8.1. Normative References [BCP115] Hansen, T., Hardie, T., and L. Masinter, "Guidelines and Registration Procedures for New URI Schemes", BCP 35, RFC 4395, February 2006. [ISO10646] International Organization for Standardization, "Information Technology - Universal Multiple-Octet Coded Character Set (UCS)", ISO/IEC 10646:2003, December 2003. [MS-DTYP] Microsoft Open Specifications, "Windows Data Types, 2.2.56 UNC", January 2013, <http://msdn.microsoft.com/en-us/library/gg465305.aspx>. [MS-NBTE] Microsoft Open Specifications, "NetBIOS over TCP (NBT) Extensions", May 2014, <http://msdn.microsoft.com/en-us/library/dd891412.aspx>. [RFC1035] Mockapetris, P., "Domain names - implementation and specification", STD 13, RFC 1035, November 1987. [RFC1123] Braden, R., "Requirements for Internet Hosts - Application and Support", STD 3, RFC 1123, October 1989. [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, January 2005. [RFC3987] Duerst, M. and M. Suignard, "Internationalized Resource Identifiers (IRIs)", RFC 3987, January 2005. Kerwin Expires July 16, 2015 [Page 14]
Internet-Draft file-scheme January 2015 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing Architecture", RFC 4291, February 2006. [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", STD 68, RFC 5234, January 2008. [RFC6874] Carpenter, B., Cheshire, S., and R. Hinden, "Representing IPv6 Zone Identifiers in Address Literals and Uniform Resource Identifiers", RFC 6874, February 2013. [UTR15] Davis, M. and K. Whistler, "Unicode Normalization Forms", August 2012. 8.2. Informative References [I-D.draft-hoffman-file-uri] Hoffman, P., "The file URI Scheme", draft-hoffman-file- uri-03 (work in progress), January 2005. [MS-SMB] Microsoft Open Specifications, "Server Message Block (SMB) Protocol", January 2013, <http://msdn.microsoft.com/en-us/library/cc246231.aspx>. [NOVELL] Novell, "NetWare Core Protocols", 2013, <http://www.novell.com/developer/ndk/ netware_core_protocols.html>. [POSIX] IEEE, "IEEE Std 1003.1, 2013 Edition", 2013. [RFC1630] Berners-Lee, T., "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", RFC 1630, June 1994. [RFC1738] Berners-Lee, T., Masinter, L., and M. McCahill, "Uniform Resource Locators (URL)", RFC 1738, December 1994. [RFC3530] Shepler, S., Callaghan, B., Robinson, D., Thurlow, R., Beame, C., Eisler, M., and D. Noveck, "Network File System (NFS) version 4 Protocol", RFC 3530, April 2003. [RFC7231] Fielding, R. and J. Reschke, "Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content", RFC 7231, June 2014. [STD63] Yergeau, F., "UTF-8, a transformation format of ISO 10646", STD 63, RFC 3629, November 2003. Kerwin Expires July 16, 2015 [Page 15]
Internet-Draft file-scheme January 2015 [WHATWG-URL] WHATWG, "URL Living Standard", May 2013, <http://url.spec.whatwg.org/>. [Win32-Namespaces] Microsoft Developer Network, "Naming Files, Paths, and Namespaces", June 2013. Appendix A. UNC Syntax 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: 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> o "netbios-name" from [MS-NBTE], Section 2.2.1. o "fqdn" from [RFC1035] or [RFC1123] o "ip-address" from Section 2.1 of [RFC1123], or Section 2.2 of [RFC4291]. The precise format of "sharename" depends on the protocol; see: SMB [MS-SMB], NFS [RFC3530], NCP [NOVELL]. Author's Address Matthew Kerwin QUT Email: matthew.kerwin@qut.edu.au Kerwin Expires July 16, 2015 [Page 16]