ietf-corpus

rfc-2396

Uniform Resource Identifiers (URI): Generic Syntax

T. Berners-Lee, R. Fielding, L. Masinter
date1998-08 streamLegacy statusDRAFT STANDARD pages40 canonicalhttps://www.rfc-editor.org/rfc/rfc2396 doi10.17487/RFC2396 errataview
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]

obsoleted by

updated by

updates

Extracted elements (30)

design-rationale §G.1

Section 4 (URI References) was added specifically to resolve confusion about whether fragment identifiers are part of a URI. Fragments are syntactically associated with URI references but are not part of the URI itself; their semantics depend on the retrieved media type.

design-rationale §G.2

The slash '/' was treated as part of the path component (not as a separator between authority and path) because it proved impossible to accurately distinguish '<foo:/bar>' from '<foo:bar>' under the prior RFC 1738/1808 model where the slash was carried as a prefix.

design-rationale §1.5

The URI character set was restricted to digits, basic Latin letters, and a small set of graphic symbols to enable global transcribability across different media (paper, radio, computer input) and keyboard layouts. The ability to transcribe identifiers was considered more important than using maximally meaningful component names.

design-rationale §G.2

The 'user:password' form from RFC 1738 was replaced by a generic 'userinfo' token and the password made scheme-specific, removing even the syntactic suggestion that clear-text passwords belong in URIs.

security

interoperability-note §5.2

Due to a loophole in RFC 1630, some parsers allow the same scheme name to appear in a relative URI reference. Validating parsers should mark such references as errors; for backwards compatibility, an implementation may strip the scheme if it matches the base URI and is known to use hier_part syntax.

interoperability-note §3.2.2

Literal IPv6 addresses are not supported as the host part of a URL in this specification; a suitable representation was desired but had not been determined or implemented in practice at time of publication.

interoperability-note §6

Scheme and hostname are case insensitive for equivalence purposes; a URL with an explicit ':port' equal to the scheme default is equivalent to one where the port is omitted. Scheme-specific normalization algorithms may additionally permit unescaping of unreserved characters.

interoperability-note §5.2

Some WWW client implementations fail to separate the reference's query component from its path before merging with the base path in step 6 of relative resolution, which may cause loss of information if the query contains '/../' or '/./'.

normative-requirement §2.2 MUST

Data conflicting with a component's reserved characters must be escaped before forming the URI. The percent character '%' must itself be escaped as '%25' when used as data.

normative-requirement §2.4.3 MUST

Data corresponding to excluded US-ASCII characters (controls 00-1F and 7F, space, '<', '>', '#', '%', '"', and 'unwise' characters) must be escaped in order to be properly represented within a URI.

normative-requirement §2.4.2 SHOULD NOT

Implementations should not escape or unescape the same string more than once, since unescaping an already-unescaped string may misinterpret a literal percent as an escape prefix, and vice versa.

normative-requirement §5.1.4 MUST

It is the responsibility of the distributor(s) of a document containing relative URIs to ensure that the base URI for that document can be established. Relative URI cannot be used reliably when the document's base URI is not well-defined.

normative-requirement §3.1 SHOULD

Programs interpreting URI SHOULD treat upper-case letters as equivalent to lower case in scheme names (e.g., accept 'HTTP' as equivalent to 'http') for resiliency.

normative-requirement §3.2.2 RECOMMENDED

The use of a password within the userinfo component of a URL is NOT RECOMMENDED because passing authentication information in clear text has proven to be a security risk in almost every case where it has been used.

security

normative-requirement §4.3 MUST

When a URI is being parsed, the greedy (left-most) algorithm is used to disambiguate an authority component from a path beginning with two slash characters; the authority component wins.

protocol-element §4.1

A fragment identifier is separated from the URI by '#' and consists of *uric characters. It is not part of the URI itself; its interpretation is a property of the media type of the retrieval result.

protocol-element §3

A URI-reference is defined as an optional absolute or relative URI followed by an optional fragment identifier separated by '#'. The four main components of an absolute hierarchical URI are scheme, authority, path, and query, written as <scheme>://<authority><path>?<query>.

protocol-element §5.1

Base URI precedence is determined in four layers (innermost wins): (1) base URI embedded in document content; (2) base URI of the encapsulating entity; (3) URI used to retrieve the entity (using the last URI after redirects); (4) application-defined default base URI.

protocol-element §2.2

Reserved characters are ';', '/', '?', ':', '@', '&', '=', '+', '$', ','. They are allowed in a URI but may not be used as data within a particular component without escaping, as they serve as component delimiters.

protocol-element §3.2

The authority component takes the form server | reg_name, is preceded by '//', and is terminated by the next '/', '?', or end of URI. The server form is [ [ userinfo '@' ] hostport ] where userinfo may carry authentication information.

protocol-element §3.3

The path component contains path_segments separated by '/', where each segment may include semicolon-delimited parameters. The path and opaque_part are mutually exclusive for any given URI and treated as a single component by parsers.

protocol-element §3.1

The scheme component must begin with an alpha character and may be followed by any combination of lower-case letters, digits, plus, period, or hyphen: scheme = alpha *( alpha | digit | '+' | '-' | '.' ).

protocol-element §3.2.2

The server-based naming authority uses the syntax <userinfo>@<host>:<port>. The host is either a hostname (dot-separated domain labels) or an IPv4address (four dot-separated decimal digit groups); literal IPv6 addresses are not supported.

protocol-element §2.3

Unreserved characters are alphanum | mark, where mark = '-' | '_' | '.' | '!' | '~' | '*' | '\'' | '(' | ')'. These characters can be escaped without changing URI semantics, but escaping should be avoided unless required by context.

security-consideration §7

A URL specifying a non-default port number may cause a client to contact a server running a different protocol, and URL content interpreted by that protocol may trigger unexpected or damaging remote operations. Caution is advised especially for port numbers within the reserved space.

security

security-consideration §7

Escaped delimiters significant to a given protocol (e.g., CR and LF for telnet) must not be unescaped before transmission, to avoid simulating extra operations or parameters that could lead to unintended remote actions.

security

security-consideration §7

There is no guarantee that a URL will continue to locate the same resource, nor that it will not locate a different resource later, due to the lack of constraints on how an authority apportions its namespace.

security

security-consideration §7

Use of a password within the userinfo component of a URL is strongly disrecommended except in the rare case where the password is intended to be public, because clear-text credentials in URI have proven a security risk in nearly every use case.

security

state-machine §5.2

Relative URI resolution proceeds in 7 ordered steps: (1) parse reference into components; (2) if all components empty/undefined, reference is current document; (3) if scheme is defined, use as absolute URI; (4) inherit authority from base if undefined; (5) if path starts with '/', use as absolute path; (6) merge relative path with base path using dot-segment removal algorithm; (7) recombine components into absolute URI.

wire-format §2.4.1

An escaped octet is encoded as a triplet: the percent character '%' followed by exactly two hexadecimal digits representing the octet value, e.g., '%20' for US-ASCII space. escaped = '%' hex hex.