HTTPbis Working Group J. Reschke
Internet-Draft greenbytes
Updates: 2616 (if approved) September 3, 2010
Intended status: Standards Track
Expires: March 7, 2011
Use of the Content-Disposition Header Field in theHypertext Transfer Protocol (HTTP)draft-ietf-httpbis-content-disp-00
Abstract
HTTP/1.1 defines the Content-Disposition response header field, but
points out that it is not part of the HTTP/1.1 Standard. This
specification takes over the definition and registration of Content-
Disposition, as used in HTTP, and clarifies internationalization
aspects.
Editorial Note (To be removed by RFC Editor before publication)
This specification is expected to replace the definition of Content-
Disposition in the HTTP/1.1 specification, as currently revised by
the IETF HTTPbis working group. See also
<http://www3.tools.ietf.org/wg/httpbis/trac/ticket/123>.
Discussion of this draft should take place on the HTTPBIS working
group mailing list (ietf-http-wg@w3.org). The current issues list is
at <http://trac.tools.ietf.org/wg/httpbis/trac/query?component=content-disp> and related documents (including fancy
diffs) can be found at <http://tools.ietf.org/wg/httpbis/>.
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 March 7, 2011.
Reschke Expires March 7, 2011 [Page 1]

Internet-Draft Content-Disposition in HTTP September 20101. Introduction
HTTP/1.1 defines the Content-Disposition response header field in
Section 19.5.1 of [RFC2616], but points out that it is not part of
the HTTP/1.1 Standard (Section 15.5):
Content-Disposition is not part of the HTTP standard, but since it
is widely implemented, we are documenting its use and risks for
implementers.
This specification takes over the definition and registration of
Content-Disposition, as used in HTTP. Based on interoperability
testing with existing User Agents, it fully defines a profile of the
features defined in the Multipurpose Internet Mail Extensions (MIME)
variant ([RFC2183]) of the header field, and also clarifies
internationalization aspects.
2. 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].
This specification uses the augmented BNF notation defined in Section2.1 of [RFC2616], including its rules for linear whitespace (LWS).
3. Header Field Definition
The Content-Disposition response header field is used to convey
additional information about how to process the response payload, and
also can be used to attach additional metadata, such as the filename.
Reschke Expires March 7, 2011 [Page 4]

Internet-Draft Content-Disposition in HTTP September 2010
user decides to save the contents of the current page being
displayed).
"filename" and "filename*" behave the same, except that "filename*"
uses the encoding defined in [RFC5987], allowing the use of
characters not present in the ISO-8859-1 character set
([ISO-8859-1]). When both "filename" and "filename*" are present, a
recipient SHOULD pick "filename*" and ignore "filename" - this will
make it possible to send the same header value to clients that do not
support "filename*".
It is essential that user agents treat the specified filename as
advisory only, thus be very careful in extracting the desired
information. In particular:
o When the value contains path separator characters, all but the
last segment SHOULD be ignored. This prevents unintentional
overwriting of well-known file system location (such as "/etc/
passwd").
o Many platforms do not use Internet Media Types ([RFC2046]) to hold
type information in the file system, but rely on filename
extensions instead. Trusting the server-provided file extension
could introduce a privilege escalation when later on the file is
opened locally (consider ".exe"). Thus, recipients need to ensure
that a file extension is used that is safe, optimally matching the
media type of the received payload.
o Other aspects recipients need to be aware of are names that have a
special meaning in the filesystem or in shell commands, such as
"." and "..", "~", "|", and also device names.
3.4. Disposition Parameter: Extensions
To enable future extensions, unknown parameters SHOULD be ignored
(see also [RFC2183], Section 2.8).
3.5. Extensibility
Note that Section 9 of [RFC2183] defines IANA registries both for
disposition types and disposition parameters. This registry is
shared by different protocols using Content-Disposition, such as MIME
and HTTP. Therefore, not all registered values may make sense in the
context of HTTP.
Reschke Expires March 7, 2011 [Page 6]

Internet-Draft Content-Disposition in HTTP September 20104. Examples
Direct UA to show "save as" dialog, with a filename of "foo.html":
Content-Disposition: Attachment; filename=foo.html
Direct UA to behave as if the Content-Disposition header field wasn't
present, but to remember the filename "foo.html" for a subsequent
save operation:
Content-Disposition: INLINE; FILENAME= "foo.html"
Direct UA to show "save as" dialog, with a filename of "an example":
Content-Disposition: Attachment; Filename*=UTF-8'en'an%20example
Note that this example uses the extended encoding defined in
[RFC5987] to specify that the natural language of the filename is
English, and also to encode the space character which is not allowed
in the token production.
Direct UA to show "save as" dialog, with a filename containing the
Unicode character U+20AC (EURO SIGN):
Content-Disposition: attachment; filename*= UTF-8''%e2%82%ac%20rates
Here, the encoding defined in [RFC5987] is also used to encode the
non-ISO-8859-1 character.
Same as above, but adding the "filename" parameter for compatibility
with user agents not implementing RFC 5987:
Content-Disposition: attachment; filename="EURO rates";
filename*=utf-8''%e2%82%ac%20rates
Note: as of August 2010, many user agents unfortunately did not
properly handle unexpected parameters, and some that implement RFC5987 did not pick the extended parameter when both were present.
5. Internationalization Considerations
The "filename*" parameter (Section 3.3), using the encoding defined
in [RFC5987], allows the server to transmit characters outside the
ISO-8859-1 character set, and also to optionally specify the language
in use.
Future parameters might also require internationalization, in which
case the same encoding can be used.
Reschke Expires March 7, 2011 [Page 7]

Internet-Draft Content-Disposition in HTTP September 20106. Security Considerations
Using server-supplied information for constructing local filenames
introduces many risks. These are summarized in Section 3.3.
Furthermore, implementers also ought to be aware of the Security
Considerations applying to HTTP (see Section 15 of [RFC2616]), and
also the parameter encoding defined in [RFC5987] (see Appendix ).
7. IANA Considerations7.1. Registry for Disposition Values and Parameter
This specification does not introduce any changes to the registration
procedures for disposition values and parameters that are defined in
Section 9 of [RFC2183].
7.2. Header Field Registration
This document updates the definition of the Content-Disposition HTTP
header field in the permanent HTTP header field registry (see
[RFC3864]).
Header field name: Content-Disposition
Applicable protocol: http
Status: standard
Author/Change controller: IETF
Specification document: this specification (Section 3)
8. Acknowledgements
Thanks to Rolf Eike Beer, Alfred Hoenes, and Roar Lauritzsen for
their valuable feedback.
9. References9.1. Normative References
[ISO-8859-1] International Organization for Standardization,
"Information technology -- 8-bit single-byte coded
graphic character sets -- Part 1: Latin alphabet No.
1", ISO/IEC 8859-1:1998, 1998.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Reschke Expires March 7, 2011 [Page 8]

Internet-Draft Content-Disposition in HTTP September 2010
not check the content type, and it also discourages properly
declaring the media type.
o RFC 2616 only allows "quoted-string" for the filename parameter.
This would be an exceptional parameter syntax, and also doesn't
reflect actual use.
o The definition for the disposition type "inline" ([RFC2183],
Section 2.1) has been re-added with a suggestion for its
processing.
o This specification requires support for the extended parameter
encoding defined in [RFC5987].
Appendix B. Differences compared to RFC 2183Section 2 of [RFC2183] defines several additional disposition
parameters: "creation-date", "modification-date", "quoted-date-time",
and "size". These do not appear to be implemented by any user agent,
thus have been omitted from this specification.
Appendix C. Alternative Approaches to Internationalization
By default, HTTP header field parameters cannot carry characters
outside the ISO-8859-1 ([ISO-8859-1]) character encoding (see
[RFC2616], Section 2.2). For the "filename" parameter, this of
course is an unacceptable restriction.
Unfortunately, user agent implementers have not managed to come up
with an interoperable approach, although the IETF Standards Track
specifies exactly one solution ([RFC2231], clarified and profiled for
HTTP in [RFC5987]).
For completeness, the sections below describe the various approaches
that have been tried, and explains how they are inferior to the RFC5987 encoding used in this specification.
C.1. RFC 2047 EncodingRFC 2047 defines an encoding mechanism for header fields, but this
encoding is not supposed to be used for header field parameters - see
Section 5 of [RFC2047]:
An 'encoded-word' MUST NOT appear within a 'quoted-string'.
...
Reschke Expires March 7, 2011 [Page 10]

Internet-Draft Content-Disposition in HTTP September 2010
An 'encoded-word' MUST NOT be used in parameter of a MIME Content-
Type or Content-Disposition field, or in any structured field body
except within a 'comment' or 'phrase'.
In practice, some user agents implement the encoding, some do not
(exposing the encoded string to the user), and some get confused by
it.
C.2. Percent Encoding
Some user agents accept percent encoded ([RFC3986], Section 2.1)
sequences of characters encoded using the UTF-8 ([RFC3629]) character
encoding.
In practice, this is hard to use because those user agents that do
not support it will display the escaped character sequence to the
user.
Furthermore, the first user agent to implement this did choose the
encoding based on local settings; thus making it very hard to use in
multi-lingual environments.
C.3. Encoding Sniffing
Some user agents inspect the value (which defaults to ISO-8859-1) and
switch to UTF-8 when it seems to be more likely to be the correct
interpretation.
As with the approaches above, this is not interoperable and
furthermore risks misinterpreting the actual value.
C.4. Implementations
Unfortunately, as of August 2010, neither the encoding defined in
RFCs 2231 and 5789, nor any of the alternate approaches discussed
above was implemented interoperably. Thus, this specification
recommends the approach defined in RFC 5987, which at least has the
advantage of actually being specified properly.
The table below shows the implementation support for the various
approaches: [[impls: Discuss: should we mention the implementation
status of actual UAs in a RFC? Up to the IESG to decide...]]
Reschke Expires March 7, 2011 [Page 11]