home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1997 December / Internet_Info_CD-ROM_Walnut_Creek_December_1997.iso / rfc / rfc1342 < prev    next >
Text File  |  1992-06-11  |  16KB  |  396 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. Network Working Group                                           K. Moore
  8. Request for Comments: 1342                       University of Tennessee
  9.                                                                June 1992
  10.  
  11.  
  12.       Representation of Non-ASCII Text in Internet Message Headers
  13.  
  14. Status of this Memo
  15.  
  16.    This RFC specifies an IAB standards track protocol for the Internet
  17.    community, and requests discussion and suggestions for improvements.
  18.    Please refer to the current edition of the "IAB Official Protocol
  19.    Standards" for the standardization state and status of this protocol.
  20.    Distribution of this memo is unlimited.
  21.  
  22. Abstract
  23.  
  24.    This memo describes an extension to the message format defined in [1]
  25.    (known to the IETF Mail Extensions Working Group as "RFC 1341"), to
  26.    allow the representation of character sets other than ASCII in RFC
  27.    822 message headers.  The extensions described were designed to be
  28.    highly compatible with existing Internet mail handling software, and
  29.    to be easily implemented in mail readers that support RFC 1341.
  30.  
  31. Introduction
  32.  
  33.    RFC 1341 describes a mechanism for denoting textual body parts which
  34.    are coded in various character sets, as well as methods for encoding
  35.    such body parts as sequences of printable ASCII characters.  This
  36.    memo describes similar techniques to allow the encoding of non-ASCII
  37.    text in various portions of a RFC 822 [2] message header, in a manner
  38.    which is unlikely to confuse existing message handling software.
  39.  
  40.    Like the encoding techniques described in RFC 1341, the techniques
  41.    outlined here were designed to allow the use of non-ASCII characters
  42.    in message headers in a way which is unlikely to be disturbed by the
  43.    quirks of existing Internet mail handling programs.  In particular,
  44.    some mail relaying programs are known to (a) delete some message
  45.    header fields while retaining others, (b) rearrange the order of
  46.    addresses in To or Cc fields, (c) rearrange the (vertical) order of
  47.    header fields, and/or (d) "wrap" message headers at different places
  48.    than those in the original message.  In addition, some mail reading
  49.    programs are known to have difficulty correctly parsing message
  50.    headers which, while legal according to RFC 822, make use of
  51.    backslash-quoting to "hide" special characters such as "<", ",", or
  52.    or which exploit other infrequently-used features of that
  53.    specification.
  54.  
  55.  
  56.  
  57.  
  58. Moore                                                           [Page 1]
  59.  
  60. RFC 1342                 Non-ASCII Mail Headers                June 1992
  61.  
  62.  
  63.    While it is unfortunate that these programs do not correctly
  64.    interpret RFC 822 headers, to "break" these programs would cause
  65.    severe operational problems for the Internet mail system.  The
  66.    extensions described in this memo therefore do not rely on little-
  67.    used features of RFC 822.  Instead, certain sequences of "ordinary"
  68.    printable ASCII characters (which are assumed to be unlikely to
  69.    otherwise appear in message headers) are reserved for use as encoded
  70.    data.  The characters used in these encodings are restricted to those
  71.    which do not have special meanings in the context in which the
  72.    encoded text appears.
  73.  
  74. Encodings
  75.  
  76.    An "encoded-word" is a sequence of printable ASCII characters that
  77.    begins with "=?", ends with "?=", and has two "?"s in between.  It
  78.    specifies a character set and an encoding method, and also includes
  79.    the original text encoded as ASCII characters, according to the rules
  80.    for that encoding method.
  81.  
  82.    A mail composer that implements this specification will provide a
  83.    means of inputing non-ASCII text in header fields, but will translate
  84.    these fields (or appropriate portions of these fields) into encoded-
  85.    words before inserting them into the message header.
  86.  
  87.    A mail reader that implements this specification will recognize
  88.    encoded-words when they appear in certain portions of the message
  89.    header.  Instead of displaying the encoded-word "as is", it will
  90.    reverse the encoding and display the original text in the designated
  91.    character set.
  92.  
  93.    An "encoded-word" is more precisely defined by the following EBNF
  94.    grammar, using the notation of RFC 822:
  95.  
  96.    encoded-word = "=" "?" charset "?" encoding "?" encoded-text "?" "="
  97.  
  98.    charset = token    ; legal charsets defined by RFC 1341
  99.  
  100.    encoding = token   ; Either "B" or "Q"
  101.  
  102.    token = 1*<Any CHAR except SPACE, CTLs, and tspecials>
  103.  
  104.    tspecials = "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" /
  105.                <"> / "/" / "[" / "]" / "?" / "." / "="
  106.  
  107.    encoded-text = 1*<Any printable ASCII character other than "?" or
  108.                   ; SPACE> (but see "Use of encoded-words in message
  109.                   ; headers", below)
  110.  
  111.  
  112.  
  113.  
  114. Moore                                                           [Page 2]
  115.  
  116. RFC 1342                 Non-ASCII Mail Headers                June 1992
  117.  
  118.  
  119.    An encoded-word may not be more than 75 characters long, including
  120.    charset, encoding, encoded-text, and delimiters.  If it is desirable
  121.    to encode more text than will fit in an encoded-word of 75
  122.    characters, multiple encoded-words (separated by SPACE or newline)
  123.    may be used.  Message header lines that contain one or more encoded-
  124.    words should be no more than 76 characters long.  NOTE: These
  125.    restrictions are included not only to ease interoperbility through
  126.    internetwork mail gateways, but also to impose a limit on the amount
  127.    of lookahead a header parser must employ (while looking for a final
  128.    ?= delimiter) before it can decide whether a token is an encoded-word
  129.    or something else.
  130.  
  131.    Initially, the legal values for "encoding" are "Q" and "B".  These
  132.    encodings are described below.  The "Q" encoding is recommended for
  133.    use with Latin character sets, and the "B" encoding for all others.
  134.    Nevertheless, a mail reader which claims to recognize encoded-words
  135.    MUST be able to accept either encoding for any character set which it
  136.    supports.
  137.  
  138.    Only a subset of the printable ASCII characters may be used in
  139.    encoded-text.  The SPACE character is not allowed, so that the
  140.    beginning and end of an encoded-word are obvious.  The "?" character
  141.    is used within an encoded-word to separate the various portions of
  142.    the encoded-word from one another, and thus cannot appear in the
  143.    encoded-text portion.  Other characters are also illegal in certain
  144.    contexts.  For example, an encoded-word in a "phrase" preceeding an
  145.    address in a From header field may not contain any of the "specials"
  146.    defined in RFC 822.  Finally, certain other characters are disallowed
  147.    in some contexts, to ensure reliability for messages that pass
  148.    through internetwork mail gateways.
  149.  
  150.    The "B" encoding automatically meets these requirements.  The "Q"
  151.    encoding allows a wide range of printable characters to be used in
  152.    non-critical locations in the message header (e.g., Subject), with
  153.    fewer characters available for use in other locations.
  154.  
  155. The "B" encoding
  156.  
  157.    The "B" encoding is identical to the "BASE64" encoding defined by RFC
  158.    1341.
  159.  
  160. The "Q" encoding
  161.  
  162.    The "Q" encoding is similar to the "Quoted-Printable" content-
  163.    transfer-encoding defined in RFC 1341.  It is designed to allow text
  164.    containing mostly ASCII characters to be decipherable on an ASCII
  165.    terminal without decoding.
  166.  
  167.  
  168.  
  169.  
  170. Moore                                                           [Page 3]
  171.  
  172. RFC 1342                 Non-ASCII Mail Headers                June 1992
  173.  
  174.  
  175.    1.  Any 8-bit value may be represented by a "=" followed by two
  176.        hexadecimal digits.  For example, if the character set in use
  177.        were ISO-8859-1, the "=" character would thus be encoded as
  178.        "=3D", and a SPACE by "=20".
  179.  
  180.    2.  The 8-bit hexadecimal value 20 (e.g., IS0-8859-1 SPACE) may be
  181.        represented as "_" (underscore, ASCII 95.).  (This character may
  182.        not pass through some internetwork mail gateways, but its use
  183.        will greatly enhance readability of "Q" encoded data with mail
  184.        readers that do not support this encoding.)  Note that the "_"
  185.        always represents hexadecimal 20, even if the SPACE character
  186.        occupies a different code position in the character set in use.
  187.  
  188.    3.  8-bit values which correspond to printable ASCII characters other
  189.        than "=", "?", "_" (underscore), and SPACE may be represented as
  190.        those characters.  (But see "Use of encoded-words in message
  191.        headers", below).
  192.  
  193. Character sets
  194.  
  195.    In an encoded-word, the character set associated with the unencoded
  196.    text is specified by a charset.  A charset can be any of the
  197.    character set names allowed in an RFC 1341 "charset" parameter of a
  198.    "text/plain" body part.  (See section 7.1.1 of RFC 1341 for a list of
  199.    valid charset parameters).
  200.  
  201.    When there is a possibility of using more than one character set to
  202.    represent the text in an encoded-word, and in the absence of private
  203.    agreements between sender and recipients of a message, it is
  204.    recommended that members of the ISO-8859-* series be used in
  205.    preference to other character sets.  Among the various ISO-8859-*
  206.    character sets, the lowest-numbered set which contains all of the
  207.    required characters should be used.
  208.  
  209. Use of encoded-words in message headers
  210.  
  211.    A sequence of one or more encoded-words is used to represent non-
  212.    ASCII textual data within a header field.  An encoded-word must be
  213.    separated from an adjacent encoded-word, "word", "text", "ctext", or
  214.    "special" by a linear white-space character or a newline.  When
  215.    displaying a particular header field" (in the RFC 822 sense)
  216.    containing one or more encoded-words, an unencoded SPACE character
  217.    that immediately follows the encoded-word is not displayed.  A
  218.    newline that immediately follows an encoded-word is not displayed
  219.    unless the encoded-word is the last token in that "field".  (This is
  220.    to allow the use of multiple encoded-words to represent long strings
  221.    of unencoded text, without having to separate encoded-words where
  222.    spaces occur in the unencoded text.)
  223.  
  224.  
  225.  
  226. Moore                                                           [Page 4]
  227.  
  228. RFC 1342                 Non-ASCII Mail Headers                June 1992
  229.  
  230.  
  231.    An encoded-word may appear in a message header or body part header
  232.    according to the following rules:
  233.  
  234. - An encoded-word may replace a "text" token (as defined by RFC 822) in:
  235.   (1) a Subject or Comments header field, (2) any extension message
  236.   header field, (3) any user-defined message header field, or (4) any
  237.   RFC 1341 body part header field (such as Content-Description) for
  238.   which the field body contains only "text"s.
  239.  
  240. - An encoded-word may appear within a comment delimited by "(" and ")",
  241.   i.e., wherever a "ctext" is allowed.  More precisely, the RFC 822 EBNF
  242.   definition for "comment" is amended as follows:
  243.  
  244.   comment = "(" *(ctext / quoted-pair / comment / encoded-word) ")"
  245.  
  246.   A "Q"-encoded encoded-word which appears in a comment MUST NOT contain
  247.   the characters "(", ")" or "\".
  248.  
  249. - As a replacement for a "word" entity within a "phrase", for example,
  250.   one that precedes an address in a From, To, or Cc header.  The EBNF
  251.   definition for phrase from RFC 822 thus becomes:
  252.  
  253.   phrase = 1*(encoded-word / word)
  254.  
  255.   In this case the set of characters that may be used in a "Q"-encoded
  256.   encoded-word is restricted to: <upper and lower case ASCII letters,
  257.   decimal digits, "!", "*", "+", "-", "/", "=", and "_" (underscore,
  258.   ASCII 95.)>.
  259.  
  260.   These are the ONLY locations where an encoded-word may appear.  In
  261.   particular, an encoded-word MUST NOT appear in any portion of an
  262.   "address".  In addition, an encoded-word MUST NOT be used in a
  263.   Received header field.
  264.  
  265.   Whenever such words appear in a header being displayed, an enlightened
  266.   mail reader will decode the text and render it appropriately.
  267.  
  268.   Only textual data (printable and white space characters) should be
  269.   encoded using this scheme.  However, since these encoding schemes
  270.   allow the encoding of arbitrary 8-bit values, mail readers that
  271.   implement this decoding should also ensure that display of the
  272.   decoded data on the recipient's terminal will not cause unwanted
  273.   side-effects.
  274.  
  275.   Use of these methods to encode non-textual data (e.g., pictures or
  276.   sounds) is not defined by this memo.  Use of encoded-words to
  277.   represent strings of purely ASCII characters is allowed, but
  278.   discouraged.
  279.  
  280.  
  281.  
  282. Moore                                                           [Page 5]
  283.  
  284. RFC 1342                 Non-ASCII Mail Headers                June 1992
  285.  
  286.  
  287. Recognition of encoded-words in message headers.
  288.  
  289.    An encoded-word may be distinguished from an ordinary "word", "text",
  290.    or "ctext", as follows: An encoded-word begins with "=?", ends with
  291.    "?=", contains exactly four "?" characters including the delimiters,
  292.    and is followed by a SPACE or newline.  If the "word", "text", or
  293.    "ctext" does not meet the above tests, it should be displayed as it
  294.    appears in the message header.
  295.  
  296.    If the mail reader does not support the character set used, it may
  297.    either display the encoded-word as ordinary text (i.e., as it appears
  298.    in the header), or it may substitute an appropriate message
  299.    indicating that the decoded text could not be displayed.
  300.  
  301. Conformance
  302.  
  303.    A mail composing program claiming compliance with this specification
  304.    MUST ensure that any string of printable ASCII characters in a
  305.    message header that begins with "=?" and ends with "?=" be a valid
  306.    encoded-word.
  307.  
  308.    A mail reading program claiming compliance with this specification
  309.    must be able to distinguish encoded-words from "text", "ctext", or
  310.    "word"s anytime they appear in appropriate places in message headers.
  311.    The program must be able to display unencoded text if the character
  312.    set is "US-ASCII".  For the ISO-8859-* character sets, the mail
  313.    reading program must at least be able to display the characters which
  314.    are also in the ASCII set.
  315.  
  316. Examples
  317.  
  318.    From: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu>
  319.    To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>
  320.    CC: =?ISO-8859-1?Q?Andr=E9_?= Pirard <PIRARD@vm1.ulg.ac.be>
  321.    Subject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=
  322.     =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=
  323.  
  324.    From: =?ISO-8859-1?Q?Olle_J=E4rnefors?= <ojarnef@admin.kth.se>
  325.    To: ietf-822@dimacs.rutgers.edu, ojarnef@admin.kth.se
  326.    Subject: Time for ISO 10646?
  327.  
  328.    To: Dave Crocker <dcrocker@mordor.stanford.edu>
  329.    Cc: ietf-822@dimacs.rutgers.edu, paf@comsol.se
  330.    From: =?ISO-8859-1?Q?Patrik_F=E4ltstr=F6m?= <paf@nada.kth.se>
  331.    Subject: Re: RFC-HDR care and feeding
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338. Moore                                                           [Page 6]
  339.  
  340. RFC 1342                 Non-ASCII Mail Headers                June 1992
  341.  
  342.  
  343.    From: Nathaniel Borenstein <nsb@thumper.bellcore.com>
  344.            (=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=)
  345.    To: Greg Vaudreuil <gvaudre@NRI.Reston.VA.US>, Ned Freed
  346.    <ned@innosoft.com>,
  347.            Keith Moore <moore@cs.utk.edu>
  348.    Subject: Test of new header generator
  349.    MIME-Version: 1.0
  350.    Content-type: text/plain; charset=ISO-8859-1
  351.  
  352. References
  353.  
  354.    [1] Borenstein N., and N. Freed, "MIME (Multipurpose Internet Mail
  355.        Extensions):  Mechanisms for Specifying and Describing the Format
  356.        of Internet Message Bodies", RFC 1341, Bellcore, Innosoft,
  357.        June 1992.
  358.  
  359.    [2] Crocker, D., "Standard for the Format of ARPA Internet Text
  360.        Messages", RFC 822, UDEL, August 1982.
  361.  
  362. Security Considerations
  363.  
  364.    Security issues are not discussed in this memo.
  365.  
  366. Author's Address
  367.  
  368.    Keith Moore
  369.    University of Tennessee
  370.    107 Ayres Hall
  371.    Knoxville TN 37996-1301
  372.  
  373.    EMail: moore@cs.utk.edu
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394. Moore                                                           [Page 7]
  395.  
  396.