ietf-corpus

rfc-1522

MIME (Multipurpose Internet Mail Extensions) Part Two: Message Header Extensions for Non-ASCII Text

K. Moore
date1993-09 streamIETF areaapp wg822ext statusDRAFT STANDARD pages10 canonicalhttps://www.rfc-editor.org/rfc/rfc1522 doi10.17487/RFC1522 errataview
This memo describes an extension to the message format defined in RFC 1521, to allow the representation of character sets other than ASCII in RFC 822 (STD 11) message headers. The extensions described were designed to be highly compatible with existing Internet mail handling software, and to be easily implemented in mail readers that support RFC 1521.

obsoleted by

obsoletes

Extracted elements (24)

design-rationale §3

In the absence of private agreements, ISO-8859-* character sets are recommended over other charsets when multiple options could represent the same text, to maximize interoperability across the installed base of mail readers.

email

design-rationale §2

The 75-character limit per encoded-word was chosen both to ease interoperability through internetwork mail gateways and to bound the lookahead required by a header parser searching for a final '?=' delimiter before deciding whether a token is an encoded-word.

email

design-rationale §1

The encoded-word mechanism uses only 'ordinary' printable ASCII characters and deliberately avoids relying on infrequently-used RFC 822 features (e.g., backslash-quoting) because existing mail relaying programs are known to delete, reorder, or rewrap headers and misparse rare RFC 822 constructs. Breaking those programs would cause severe operational problems.

email

design-rationale §4

The 'Q' encoding is recommended when most characters are ASCII (leaving the text largely readable without decoding), while 'B' (BASE64) is recommended otherwise. This distinction reflects the different readability trade-offs for human inspection of raw headers.

email

design-rationale §4.2

The underscore '_' in Q encoding represents hex 20 (SPACE) to greatly enhance readability of Q-encoded data on mail readers that do not support this encoding, even though the underscore may not pass through some internetwork mail gateways.

email

interoperability-note §1

The design explicitly accommodates known deficiencies in deployed mail software: programs that delete some header fields, rearrange To/Cc addresses, reorder header fields vertically, or wrap headers at different column positions than the original. Encoded-words are designed to survive these transformations intact.

email

interoperability-note §6.2

When a mail reader does not support the encoding or character set used in an encoded-word, it may display the raw encoded-word as ordinary text, make a best-effort display, or substitute an explanatory message — no single fallback behavior is mandated.

email

normative-requirement §7 MUST

A compliant mail reading program MUST support both 'B' and 'Q' encodings for every character set it supports, MUST be able to display unencoded text when the charset is 'US-ASCII', and for ISO-8859-* charsets must at least display characters also present in ASCII.

email

normative-requirement §7 MUST

A mail composing program claiming compliance MUST ensure that any string within '*text' or '*ctext' that begins with '=?' and ends with '?=' is a valid encoded-word. Any 'word' within a 'phrase' matching that pattern must also be valid.

email

normative-requirement §6.3 MUST NOT

A mail reader MUST NOT prevent the display or handling of a message solely because an encoded-word is incorrectly formed. A mail reader need not attempt to display the text of a malformed encoded-word, but must not block the entire message.

email

normative-requirement §4 MUST

A mail reader that claims to recognize encoded-words MUST be able to accept either the 'B' or 'Q' encoding for any character set it supports, regardless of which encoding is preferred for that character set.

email

normative-requirement §5 MUST NOT

A 'Q'-encoded encoded-word appearing inside a comment MUST NOT contain the characters '(', ')', or '\'.

email

normative-requirement §5 MUST

An encoded-word in a 'text' header field MUST be separated from any adjacent encoded-word or 'text' by linear-white-space. Similarly, encoded-words within 'phrase' and 'comment' contexts must be separated from adjacent tokens by linear-white-space.

email

normative-requirement §5 MUST NOT

An encoded-word MUST NOT appear in any portion of an 'addr-spec', and MUST NOT be used in a Received header field. These are the only explicitly prohibited locations.

email

normative-requirement §2 MUST NOT

An encoded-word MUST NOT be more than 75 characters long, including charset, encoding, encoded-text, and delimiters. Each line of a header field containing one or more encoded-words is limited to 76 characters.

email

normative-requirement §5 MUST

Each encoded-word MUST encode an integral number of octets, and the encoded-text must be well-formed within a single encoded-word — encoding cannot be continued in the next encoded-word. Additionally, a multi-octet character MUST NOT be split across adjacent encoded-words.

email

protocol-element §5

Encoded-words are permitted in exactly three locations: (1) replacing a 'text' token in Subject, Comments, extension, or X- header fields; (2) within a 'comment' (wherever 'ctext' is allowed); (3) as a replacement for a 'word' within a 'phrase' (e.g., before an address in From/To/Cc).

email

protocol-element §4.1

The 'B' encoding is identical to the BASE64 encoding defined by RFC 1521. It is recommended when most characters to be encoded are not in the ASCII character set.

email

protocol-element §3

The charset field of an encoded-word may be any character set name permitted in an RFC 1521 'text/plain' charset parameter or any IANA-registered MIME text/plain charset. If a charset uses code-switching, the encoded-word must end with control codes that restore ASCII mode.

email

protocol-element §4.2

The 'Q' encoding is similar to Quoted-Printable from RFC 1521. Any 8-bit value may be represented as '=' followed by two uppercase hexadecimal digits; the underscore '_' always represents hexadecimal 20 (SPACE), regardless of SPACE's code position in the character set in use.

email

protocol-element §6.2

When displaying a header field containing multiple encoded-words, any linear-white-space separating a pair of adjacent encoded-words is ignored, allowing long unencoded strings to be represented across multiple encoded-words without introducing spurious spaces.

email

protocol-element §5

Within a 'phrase' context, the set of characters usable in a Q-encoded encoded-word is restricted to upper and lower case ASCII letters, decimal digits, '!', '*', '+', '-', '/', '=', and '_' (underscore).

email

security-consideration §10

The RFC explicitly states that security issues are not discussed. However, section 5 notes that mail readers implementing decoding must ensure display of decoded data on the recipient's terminal will not cause unwanted side-effects, implicitly flagging the risk of terminal escape sequences or other hostile content embedded in encoded-words.

email, security

wire-format §2

An encoded-word has the form '=?' charset '?' encoding '?' encoded-text '?=', where charset and encoding are tokens (no whitespace, no especials), and encoded-text is printable ASCII excluding '?' and SPACE. Both charset and encoding names are case-independent.

email