RFC 1806 EXPERIMENTAL EMAIL · MIME · MESSAGE FORMAT

Communicating Presentation Information in Internet Messages: The Content-Disposition Header

A header that tells email clients whether to show message parts inline or as downloadable attachments.

On rfc-editor.org ↗
PUBLISHED
June 1995
AUTHORS
R. Troost, S. Dorner
STREAM
Legacy
OBSOLETED BY
RFC 2183 — Content-Disposition
DISPOSITION TYPES
inline, attachment
DOI
10.17487/RFC1806

RFC text

Contents
Original text · RFC Editor View on rfc-editor.org ↗
Network Working Group                                          R. Troost
Request for Comments: 1806                           New Century Systems
Category: Experimental                                         S. Dorner
                                                   QUALCOMM Incorporated
                                                               June 1995


               Communicating Presentation Information in
                           Internet Messages:
                     The Content-Disposition Header

Status of this Memo

   This memo defines an Experimental Protocol for the Internet
   community.  This memo does not specify an Internet standard of any
   kind.  Discussion and suggestions for improvement are requested.
   Distribution of this memo is unlimited.

Abstract

   This memo provides a mechanism whereby messages conforming to the
   [RFC 1521] ("MIME") specification can convey presentational
   information.  It specifies a new "Content-Disposition" header,
   optional and valid for any [RFC 1521] entity ("message" or "body
   part"). Two values for this header are described in this memo; one
   for the ordinary linear presentation of the body part, and another to
   facilitate the use of mail to transfer files. It is expected that
   more values will be defined in the future, and procedures are defined
   for extending this set of values.

   This document is intended as an extension to [RFC 1521]. As such, the
   reader is assumed to be familiar with [RFC 1521], and [RFC 822]. The
   information presented herein supplements but does not replace that
   found in those documents.

1.  Introduction

   [RFC 1521] specifies a standard format for encapsulating multiple
   pieces of data into a single Internet message. That document does not
   address the issue of presentation styles; it provides a framework for
   the interchange of message content, but leaves presentation issues
   solely in the hands of mail user agent (MUA) implementors.

   Two common ways of presenting multipart electronic messages are as a
   main document with a list of separate attachments, and as a single
   document with the various parts expanded (displayed) inline. The
   display of an attachment is generally construed to require positive
   action on the part of the recipient, while inline message components
   are displayed automatically when the message is viewed. A mechanism
   is needed to allow the sender to transmit this sort of presentational
   information to the recipient; the Content-Disposition header provides
   this mechanism, allowing each component of a message to be tagged
   with an indication of its desired presentation semantics.

   Tagging messages in this manner will often be sufficient for basic
   message formatting. However, in many cases a more powerful and
   flexible approach will be necessary. The definition of such
   approaches is beyond the scope of this memo; however, such approaches
   can benefit from additional Content-Disposition values and
   parameters, to be defined at a later date.

   In addition to allowing the sender to specify the presentational
   disposition of a message component, it is desirable to allow her to
   indicate a default archival disposition; a filename. The optional
   "filename" parameter provides for this.

2.  The Content-Disposition Header Field

   Content-Disposition is an optional header; in its absence, the MUA
   may use whatever presentation method it deems suitable.

   It is desirable to keep the set of possible disposition types small
   and well defined, to avoid needless complexity. Even so, evolving
   usage will likely require the definition of additional disposition
   types or parameters, so the set of disposition values is extensible;
   see below.

   In the extended BNF notation of [RFC 822], the Content-Disposition
   header field is defined as follows:

        disposition := "Content-Disposition" ":"
                       disposition-type
                       *(";" disposition-parm)

        disposition-type := "inline"
                          / "attachment"
                          / extension-token
                          ; values are not case-sensitive

        disposition-parm := filename-parm / parameter

        filename-parm := "filename" "=" value;

   `Extension-token', `parameter' and `value' are defined according to
   [RFC 822] and [RFC 1521].

2.1  The Inline Disposition Type

   A bodypart should be marked `inline' if it is intended to be
   displayed automatically upon display of the message. Inline bodyparts
   should be presented in the order in which they occur, subject to the
   normal semantics of multipart messages.

2.2  The Attachment Disposition Type

   Bodyparts can be designated `attachment' to indicate that they are
   separate from the main body of the mail message, and that their
   display should not be automatic, but contingent upon some further
   action of the user. The MUA might instead present the user of a
   bitmap terminal with an iconic representation of the attachments, or,
   on character terminals, with a list of attachments from which the
   user could select for viewing or storage.

2.3  The Filename Parameter

   The sender may want to suggest a filename to be used if the entity is
   detached and stored in a separate file. If the receiving MUA writes
   the entity to a file, the suggested filename should be used as a
   basis for the actual filename, where possible.

   It is important that the receiving MUA not blindly use the suggested
   filename.  The suggested filename should be checked (and possibly
   changed) to see that it conforms to local filesystem conventions,
   does not overwrite an existing file, and does not present a security
   problem (see Security Considerations below).

   The receiving MUA should not respect any directory path information
   that may seem to be present in the filename parameter.  The filename
   should be treated as a terminal component only.  Portable
   specification of directory paths might possibly be done in the future
   via a separate Content-Disposition parameter, but no provision is
   made for it in this draft.

   Current [RFC 1521] grammar restricts parameter values (and hence
   Content-Disposition filenames) to US-ASCII.  We recognize the great
   desirability of allowing arbitrary character sets in filenames, but
   it is beyond the scope of this document to define the necessary
   mechanisms.  We expect that the basic [RFC 1521] `value'
   specification will someday be amended to allow use of non-US-ASCII
   characters, at which time the same mechanism should be used in the
   Content-Disposition filename parameter.

   Beyond the limitation to US-ASCII, the sending MUA may wish to bear
   in mind the limitations of common filesystems.  Many have severe
   length and character set restrictions.  Short alphanumeric filenames
   are least likely to require modification by the receiving system.

   The presence of the filename parameter does not force an
   implementation to write the entity to a separate file. It is
   perfectly acceptable for implementations to leave the entity as part
   of the normal mail stream unless the user requests otherwise. As a
   consequence, the parameter may be used on any MIME entity, even
   `inline' ones. These will not normally be written to files, but the
   parameter could be used to provide a filename if the receiving user
   should choose to write the part to a file.

2.4  Future Extensions and Unrecognized Disposition Types

   In the likely event that new parameters or disposition types are
   needed, they should be registered with the IANA, in the manner
   specified in [RFC 1521], appendix E.

   Once new disposition types and parameters are defined, there is of
   course the likelihood that implementations will see disposition types
   and parameters they do not understand.  Furthermore, since x-tokens
   are allowed, implementations may also see entirely unregistered
   disposition types and parameters.

   Unrecognized parameters should be ignored. Unrecognized disposition
   types should be treated as `attachment'. The choice of `attachment'
   for unrecognized types is made because a sender who goes to the
   trouble of producing a Content-Disposition header with a new
   disposition type is more likely aiming for something more elaborate
   than inline presentation.

   Unless noted otherwise in the definition of a parameter, Content-
   Disposition parameters are valid for all dispositions.  (In contrast
   to [RFC 1521] content-type parameters, which are defined on a per-
   content-type basis.) Thus, for example, the `filename' parameter
   still means the name of the file to which the part should be written,
   even if the disposition itself is unrecognized.

2.5  Content-Disposition and Multipart

   If a Content-Disposition header is used on a multipart body part, it
   applies to the multipart as a whole, not the individual subparts.
   The disposition types of the subparts do not need to be consulted
   until the multipart itself is presented.  When the multipart is
   displayed, then the dispositions of the subparts should be respected.

   If the `inline' disposition is used, the multipart should be
   displayed as normal; however, an `attachment' subpart should require
   action from the user to display.

   If the `attachment' disposition is used, presentation of the
   multipart should not proceed without explicit user action.  Once the
   user has chosen to display the multipart, the individual subpart
   dispositions should be consulted to determine how to present the
   subparts.

2.6  Content-Disposition and the Main Message

   It is permissible to use Content-Disposition on the main body of an
   [RFC 822] message.

3.  Examples

   Here is a an example of a body part containing a JPEG image that is
   intended to be viewed by the user immediately:

         Content-Type: image/jpeg
         Content-Disposition: inline
         Content-Description: just a small picture of me

         <jpeg data>

   The following body part contains a JPEG image that should be
   displayed to the user only if the user requests it. If the JPEG is
   written to a file, the file should be named "genome.jpg":

         Content-Type: image/jpeg
         Content-Disposition: attachment; filename=genome.jpeg
         Content-Description: a complete map of the human genome

         <jpeg data>

   The following is an example of the use of the `attachment'
   disposition with a multipart body part.  The user should see text-
   part-1 immediately, then take some action to view multipart-2.  After
   taking action to view multipart-2, the user will see text-part-2
   right away, and be required to take action to view jpeg-1.  Subparts
   are indented for clarity; they would not be so indented in a real
   message.

         Content-Type: multipart/mixed; boundary=outer
         Content-Description: multipart-1

         --outer
           Content-Type: text/plain
           Content-Disposition: inline
           Content-Description: text-part-1

           Some text goes here

         --outer
           Content-Type: multipart/mixed; boundary=inner
           Content-Disposition: attachment
           Content-Description: multipart-2

           --inner
             Content-Type: text/plain
             Content-Disposition: inline
             Content-Description: text-part-2

             Some more text here.

           --inner
             Content-Type: image/jpeg
             Content-Disposition: attachment
             Content-Description: jpeg-1

             <jpeg data>
           --inner--
         --outer--

4.  Summary

   Content-Disposition takes one of two values, `inline' and
   `attachment'.  'Inline' indicates that the entity should be
   immediately displayed to the user, whereas `attachment' means that
   the user should take additional action to view the entity.

   The `filename' parameter can be used to suggest a filename for
   storing the bodypart, if the user wishes to store it in an external
   file.

5.  Security Considerations

   There are security issues involved any time users exchange data.
   While these are not to be minimized, neither does this memo change
   the status quo in that regard, except in one instance.

   Since this memo provides a way for the sender to suggest a filename,
   a receiving MUA must take care that the sender's suggested filename
   does not represent a hazard. Using UNIX as an example, some hazards
   would be:

          + Creating startup files (e.g., ".login").

          + Creating or overwriting system files (e.g.,
            "/etc/passwd").

          + Overwriting any existing file.

          + Placing executable files into any command search path
            (e.g., "~/bin/more").

          + Sending the file to a pipe (e.g., "| sh").

   In general, the receiving MUA should never name or place the file
   such that it will get interpreted or executed without the user
   explicitly initiating the action.

   It is very important to note that this is not an exhaustive list; it
   is intended as a small set of examples only.  Implementors must be
   alert to the potential hazards on their target systems.

6.  References

    [RFC 1521]
        Borenstein N., and N. Freed, "MIME (Multipurpose Internet
        Mail Extensions) Part One:  Mechanisms for Specifying and
        Describing the Format of Internet Message Bodies",
        RFC 1521, Bellcore, Innosoft, September 1993.

    [RFC 822]
        Crocker, D., "Standard for the Format of ARPA Internet
        Text Messages", STD 11, RFC 822, UDEL, August 1982.

7.  Acknowledgements

We gratefully acknowledge the help these people provided
during the preparation of this draft:

            Nathaniel Borenstein
            Ned Freed
            Keith Moore
            Dave Crocker
            Dan Pritchett

8.  Authors' Addresses

   Rens Troost
   New Century Systems
   324 East 41st Street #804
   New York, NY, 10017 USA

   Phone: +1 (212) 557-2050
   Fax: +1 (212) 557-2049
   EMail: rens@century.com


   Steve Dorner
   QUALCOMM Incorporated
   6455 Lusk Boulevard
   San Diego, CA 92121
   USA

   EMail: sdorner@qualcomm.com

AI ELI5

On this page
PROBLEMMIME messages can contain multiple parts, but senders have no standard way to tell receivers whether each part should be displayed immediately (inline) or saved separately (attachment). Mail clients have to guess, leading to inconsistent behavior.
MECHANISMThe Content-Disposition header uses two values: "inline" for parts to display immediately, and "attachment" for parts to save separately. An optional filename parameter suggests a name if the recipient saves the part to a file.
REPLACED BY RFC 2183Mail clients can now respect the sender's intent about how to present message parts, and attachments can be stored with a suggested filename, improving user experience across different email systems.

§1The Problem: How Should Email Parts Be Displayed?

MIME introduced the ability to send multiple types of content in a single email message—text, images, audio and more. However, MIME did not specify how mail clients should present these parts to users. A client might receive a message with an image, a text note, and a spreadsheet, but the RFC did not say whether the image should appear inline in the message body or presented as a separate attachment. Different mail clients made different choices, leading to a confusing user experience.

This RFC proposes a simple mechanism to let the sender indicate the desired presentation. Some parts should be displayed automatically when the message is viewed (inline), while others should be shown as separate attachments that the user opens intentionally. The mechanism also allows senders to suggest a filename for saving attachments.

Email messages can have pictures, files and other stuff in them, but the program reading the email didn't know whether to show them right away or wait for you to click to see them. This header tells it what to do.

§2The Content-Disposition Header

The Content-Disposition header is optional and can be placed on any MIME message part. Its syntax is simple: it specifies a disposition type ("inline" or "attachment", or a future extension), followed by optional parameters. The header is case-insensitive. An example inline part might be Content-Disposition: inline, while an attachment might be Content-Disposition: attachment; filename=genome.jpeg.

The specification explicitly allows for future extension. Unrecognized disposition types should be treated as "attachment" as a safe default (the assumption is that if a sender goes to the trouble of specifying a new disposition type, they intend something more elaborate than inline display). Unrecognized parameters should be ignored. Parameters apply to all disposition types unless otherwise specified, so the filename parameter works with both inline and attachment dispositions.

The header is a simple label: "inline" means show it now, "attachment" means save it. You can add a filename parameter to suggest what to call the file if someone saves it.

§3Inline and Attachment Disposition Types

An inline disposition means the mail client should display the body part automatically when the message is viewed, in the order it appears among other parts. Inline parts are presented as part of the message body. An attachment disposition means the part should not be displayed automatically; instead, the user must take explicit action (clicking a link, running a command) to view it. Mail clients might show attachments as a list or with icons, leaving it to the user to decide whether to open them.

The specification also clarifies how dispositions apply to multipart messages. If a multipart body part is marked as "attachment", the entire multipart is withheld until the user chooses to view it; the dispositions of the subparts are then consulted when the multipart is displayed. If a multipart is marked as "inline", it displays normally, but the dispositions of subparts are still respected (so an inline part within the multipart displays immediately, but an attachment subpart requires action).

"Inline" means the email program shows it right away when you open the message. "Attachment" means the program shows you a list of files you can click to open. For multipart messages, if the whole thing is an attachment, you have to open that first before seeing the parts inside.

§4The Filename Parameter and Security

The filename parameter suggests a name for the body part if the recipient saves it to a file. For example, Content-Disposition: attachment; filename=report.pdf suggests that the part be saved as "report.pdf". However, the RFC emphasizes that the receiving mail client must not blindly use the sender's suggested filename. The client should check that the filename conforms to local filesystem conventions, does not overwrite an existing file, and does not create security risks.

The RFC details specific security hazards. On UNIX systems, a filename like ".login" could create or modify a startup script, a path like "/etc/passwd" could overwrite a system file, or a filename like "../bin/trojan" could place an executable in a command search path. The client must ignore any directory path information in the filename and use only the terminal component (the filename part after any slashes). Additionally, the client should never name or place a file such that it will be automatically executed without explicit user action.

The email can suggest a filename, but the email program must be careful not to let a trick filename overwrite important files or run commands automatically. It ignores any path information and only uses the basic filename.

§5Examples of Content-Disposition Use

The RFC provides three examples. The first shows a JPEG image marked as inline with a description: Content-Type: image/jpeg followed by Content-Disposition: inline. The second shows the same image as an attachment with a suggested filename: Content-Disposition: attachment; filename=genome.jpeg. The third is a complete multipart message where the main text is inline, one multipart subpart is marked as attachment, and within that subpart, one piece is inline and another is attachment, illustrating the nesting rules.

These examples show how different dispositions work in practice and how multipart structures allow mixing inline and attachment parts in a single message.

An example shows a picture marked to display right away. Another example shows the same picture marked as an attachment with a suggested filename. A third example shows a message with mixed inline and attachment parts to show how it all works together.

§6Status and Evolution

This RFC is marked Experimental. RFC 2183 refines and updates this specification, making it a draft standard. The basic concept of Content-Disposition has become fundamental to modern email: every email client today uses or recognizes this header (or its successor) to decide whether to show an attachment as a clickable item or as part of the message body. The header is now a de facto standard for message part presentation.

This was an experimental RFC that helped prove the idea worked. Later, RFC 2183 refined it into a standard that email programs use today. Almost every email program now recognizes this header.

§7References