ietf-corpus

rfc-2047

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

K. Moore
date1996-11 streamIETF areaapp wg822ext statusDRAFT STANDARD pages15 canonicalhttps://www.rfc-editor.org/rfc/rfc2047 doi10.17487/RFC2047 errataview
This particular document is the third document in the series. It describes extensions to RFC 822 to allow non-US-ASCII text data in Internet mail header fields. [STANDARDS-TRACK]

obsoletes

updated by

Extracted elements (26)

design-rationale §4

'Q' encoding is recommended when most characters are ASCII (preserving readability without decoding), while 'B' (BASE64) is recommended otherwise. Mandating that readers accept both encodings for any supported charset prevents sender-choice lock-in and interoperability failures.

email

design-rationale §2

The 75-character per encoded-word and 76-character per line limits were chosen to ease interoperability through internetwork mail gateways and to bound the lookahead a header parser must perform before deciding whether a token is an encoded-word.

email

design-rationale §1

The encoded-word scheme uses sequences of ordinary printable ASCII (=?...?=) rather than raw 8-bit characters or obscure RFC 822 features, because existing mail relays are known to delete fields, reorder addresses, wrap headers, and misparse backslash-quoted characters — making 8-bit or non-atom approaches operationally dangerous.

email

design-rationale §4.2

The 'Q' encoding uses '_' (underscore) to represent SPACE to greatly enhance readability on ASCII terminals that do not support encoded-word decoding. The underscore always means 0x20 regardless of the code position of SPACE in the charset, even though it may not survive all mail gateways.

email

interoperability-note §6.1

A MIME-Version header field is NOT required to be present for encoded-words to be interpreted per this specification. This allows mail readers to decode encoded-words in displayed fields without first parsing the entire message header.

email

interoperability-note §6.2

It is NOT generally possible to translate a message header containing encoded-words into an unencoded form parseable by a plain RFC 822 reader. Decoding occurs after structured field parsing, so encoded-words can conceal 'special' characters indistinguishable from those in surrounding text.

email

interoperability-note §1

This specification explicitly does not define any translation between '8-bit headers' and pure ASCII headers, and no such translation is assumed to be possible. Implementations must not conflate encoded-word headers with 8-bit header schemes.

email

interoperability-note §5

Within a 'comment', the RFC 822 ABNF is amended so that 'encoded-word' is a valid alternative to 'ctext' or 'quoted-pair'. However, this rule does NOT apply to '*text' fields, where '(' and ')' are treated as ordinary characters rather than comment delimiters.

email

normative-requirement §7 MUST

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

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 this pattern must also be a valid encoded-word.

email

normative-requirement §4 MUST

A mail reader claiming 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 charset.

email

normative-requirement §6.3 MUST NOT

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

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. The same separation requirement applies within 'comment' and 'phrase' contexts.

email

normative-requirement §2 MUST NOT

An 'encoded-word' may not be more than 75 characters long, including charset, encoding, encoded-text, and delimiters. Each line of a header field that contains one or more encoded-words is limited to 76 characters.

email

normative-requirement §5 MUST NOT

An encoded-word MUST NOT appear in any portion of an 'addr-spec', within a 'quoted-string', in a Received header field, or in a parameter of a MIME Content-Type or Content-Disposition field (except within a 'comment' or 'phrase').

email

normative-requirement §3 MUST

If a charset uses code-switching techniques to leave ASCII mode, the encoded-word MUST contain additional control codes so that ASCII mode is restored at the end of that encoded-word. This rule applies separately to each encoded-word, including adjacent ones in the same field.

email

normative-requirement §5 MUST NOT

In a 'phrase' context (preceding an address), Q-encoded text is restricted to upper/lower ASCII letters, decimal digits, and the characters '!', '*', '+', '-', '/', '=', and '_'. Other characters including RFC 822 specials are not permitted.

email

normative-requirement §5 SHOULD

Only printable and white space character data should be encoded using encoded-words. Mail readers SHOULD ensure that display of decoded data will not cause unwanted side-effects on the recipient's terminal, since the encoding allows arbitrary octet values.

email, security

normative-requirement §5 MUST

The encoded-text in an encoded-word MUST be self-contained and MUST NOT be continued across encoded-words. Each encoded-word MUST encode an integral number of octets and represent an integral number of characters; a multi-octet character may not be split across adjacent encoded-words.

email

normative-requirement §6.2 MUST

When displaying a header containing multiple adjacent encoded-words, any linear-white-space separating them MUST be ignored (not displayed), allowing long strings to span multiple encoded-words without introducing spurious spaces.

email

normative-requirement §2 MUST NOT

White space characters (SPACE and HTAB) are FORBIDDEN within an encoded-word; they must be encoded (e.g., SPACE as '=20' in Q encoding). An encoded-word must appear as an 'atom' to an RFC 822 parser, so unencoded white space breaks parsing.

email

protocol-element §5

Encoded-words are permitted in exactly three contexts: (1) replacing 'text' tokens in Subject, Comments, extension, or MIME body part header fields; (2) within 'comment' delimiters wherever 'ctext' is allowed; (3) as a 'word' within a 'phrase' preceding an address in From, To, or Cc headers.

email

protocol-element §4.1

The 'B' encoding is identical to the BASE64 encoding defined in RFC 2045. The encoded-text portion of a 'B' encoded-word will always be a multiple of 4 characters long.

email

protocol-element §4.2 MUST NOT

The 'Q' encoding is similar to Quoted-Printable (RFC 2045): any 8-bit value may be encoded as '=' followed by two uppercase hex digits; '_' (underscore, ASCII 95) always represents hexadecimal 20 (SPACE); other printable ASCII characters except '=', '?', and '_' MAY be used as-is. SPACE and TAB MUST NOT appear literally.

email

security-consideration §10

The RFC states that security issues are not discussed. However, Section 6.2 identifies an implicit risk: since decoding of encoded-words occurs after structured field parsing, special characters can be hidden inside encoded-words that, when displayed, are visually indistinguishable from structural characters in surrounding text — a potential header-spoofing vector.

email, security

wire-format §2

An 'encoded-word' has the syntax: '=?' charset '?' encoding '?' encoded-text '?='. The charset and encoding are case-independent tokens; encoded-text is 1 or more printable ASCII characters excluding '?' and SPACE. White space MUST NOT appear between components.

email