| 1 |
<pre>Network Working Group K. Moore |
| 2 |
Request for Comments: 2047 University of Tennessee |
| 3 |
Obsoletes: <a href="./rfc1521">1521</a>, <a href="./rfc1522">1522</a>, <a href="./rfc1590">1590</a> November 1996 |
| 4 |
Category: Standards Track |
| 5 |
|
| 6 |
|
| 7 |
<span class="h1">MIME (Multipurpose Internet Mail Extensions) Part Three:</span> |
| 8 |
<span class="h1">Message Header Extensions for Non-ASCII Text</span> |
| 9 |
|
| 10 |
Status of this Memo |
| 11 |
|
| 12 |
This document specifies an Internet standards track protocol for the |
| 13 |
Internet community, and requests discussion and suggestions for |
| 14 |
improvements. Please refer to the current edition of the "Internet |
| 15 |
Official Protocol Standards" (STD 1) for the standardization state |
| 16 |
and status of this protocol. Distribution of this memo is unlimited. |
| 17 |
|
| 18 |
Abstract |
| 19 |
|
| 20 |
STD 11, <a href="./rfc822">RFC 822</a>, defines a message representation protocol specifying |
| 21 |
considerable detail about US-ASCII message headers, and leaves the |
| 22 |
message content, or message body, as flat US-ASCII text. This set of |
| 23 |
documents, collectively called the Multipurpose Internet Mail |
| 24 |
Extensions, or MIME, redefines the format of messages to allow for |
| 25 |
|
| 26 |
(1) textual message bodies in character sets other than US-ASCII, |
| 27 |
|
| 28 |
(2) an extensible set of different formats for non-textual message |
| 29 |
bodies, |
| 30 |
|
| 31 |
(3) multi-part message bodies, and |
| 32 |
|
| 33 |
(4) textual header information in character sets other than US-ASCII. |
| 34 |
|
| 35 |
These documents are based on earlier work documented in <a href="./rfc934">RFC 934</a>, STD |
| 36 |
11, and <a href="./rfc1049">RFC 1049</a>, but extends and revises them. Because <a href="./rfc822">RFC 822</a> said |
| 37 |
so little about message bodies, these documents are largely |
| 38 |
orthogonal to (rather than a revision of) <a href="./rfc822">RFC 822</a>. |
| 39 |
|
| 40 |
This particular document is the third document in the series. It |
| 41 |
describes extensions to <a href="./rfc822">RFC 822</a> to allow non-US-ASCII text data in |
| 42 |
Internet mail header fields. |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
<span class="grey">Moore Standards Track [Page 1]</span></pre> |
| 53 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span> |
| 54 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 55 |
|
| 56 |
|
| 57 |
Other documents in this series include: |
| 58 |
|
| 59 |
+ <a href="./rfc2045">RFC 2045</a>, which specifies the various headers used to describe |
| 60 |
the structure of MIME messages. |
| 61 |
|
| 62 |
+ <a href="./rfc2046">RFC 2046</a>, which defines the general structure of the MIME media |
| 63 |
typing system and defines an initial set of media types, |
| 64 |
|
| 65 |
+ <a href="./rfc2048">RFC 2048</a>, which specifies various IANA registration procedures |
| 66 |
for MIME-related facilities, and |
| 67 |
|
| 68 |
+ <a href="./rfc2049">RFC 2049</a>, which describes MIME conformance criteria and |
| 69 |
provides some illustrative examples of MIME message formats, |
| 70 |
acknowledgements, and the bibliography. |
| 71 |
|
| 72 |
These documents are revisions of RFCs 1521, 1522, and 1590, which |
| 73 |
themselves were revisions of RFCs 1341 and 1342. An appendix in <a href="./rfc2049">RFC</a> |
| 74 |
<a href="./rfc2049">2049</a> describes differences and changes from previous versions. |
| 75 |
|
| 76 |
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span> |
| 77 |
|
| 78 |
<a href="./rfc2045">RFC 2045</a> describes a mechanism for denoting textual body parts which |
| 79 |
are coded in various character sets, as well as methods for encoding |
| 80 |
such body parts as sequences of printable US-ASCII characters. This |
| 81 |
memo describes similar techniques to allow the encoding of non-ASCII |
| 82 |
text in various portions of a <a href="./rfc822">RFC 822</a> [2] message header, in a manner |
| 83 |
which is unlikely to confuse existing message handling software. |
| 84 |
|
| 85 |
Like the encoding techniques described in <a href="./rfc2045">RFC 2045</a>, the techniques |
| 86 |
outlined here were designed to allow the use of non-ASCII characters |
| 87 |
in message headers in a way which is unlikely to be disturbed by the |
| 88 |
quirks of existing Internet mail handling programs. In particular, |
| 89 |
some mail relaying programs are known to (a) delete some message |
| 90 |
header fields while retaining others, (b) rearrange the order of |
| 91 |
addresses in To or Cc fields, (c) rearrange the (vertical) order of |
| 92 |
header fields, and/or (d) "wrap" message headers at different places |
| 93 |
than those in the original message. In addition, some mail reading |
| 94 |
programs are known to have difficulty correctly parsing message |
| 95 |
headers which, while legal according to <a href="./rfc822">RFC 822</a>, make use of |
| 96 |
backslash-quoting to "hide" special characters such as "<", ",", or |
| 97 |
":", or which exploit other infrequently-used features of that |
| 98 |
specification. |
| 99 |
|
| 100 |
While it is unfortunate that these programs do not correctly |
| 101 |
interpret <a href="./rfc822">RFC 822</a> headers, to "break" these programs would cause |
| 102 |
severe operational problems for the Internet mail system. The |
| 103 |
extensions described in this memo therefore do not rely on little- |
| 104 |
used features of <a href="./rfc822">RFC 822</a>. |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
<span class="grey">Moore Standards Track [Page 2]</span></pre> |
| 109 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span> |
| 110 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 111 |
|
| 112 |
|
| 113 |
Instead, certain sequences of "ordinary" printable ASCII characters |
| 114 |
(known as "encoded-words") are reserved for use as encoded data. The |
| 115 |
syntax of encoded-words is such that they are unlikely to |
| 116 |
"accidentally" appear as normal text in message headers. |
| 117 |
Furthermore, the characters used in encoded-words are restricted to |
| 118 |
those which do not have special meanings in the context in which the |
| 119 |
encoded-word appears. |
| 120 |
|
| 121 |
Generally, an "encoded-word" is a sequence of printable ASCII |
| 122 |
characters that begins with "=?", ends with "?=", and has two "?"s in |
| 123 |
between. It specifies a character set and an encoding method, and |
| 124 |
also includes the original text encoded as graphic ASCII characters, |
| 125 |
according to the rules for that encoding method. |
| 126 |
|
| 127 |
A mail composer that implements this specification will provide a |
| 128 |
means of inputting non-ASCII text in header fields, but will |
| 129 |
translate these fields (or appropriate portions of these fields) into |
| 130 |
encoded-words before inserting them into the message header. |
| 131 |
|
| 132 |
A mail reader that implements this specification will recognize |
| 133 |
encoded-words when they appear in certain portions of the message |
| 134 |
header. Instead of displaying the encoded-word "as is", it will |
| 135 |
reverse the encoding and display the original text in the designated |
| 136 |
character set. |
| 137 |
|
| 138 |
NOTES |
| 139 |
|
| 140 |
This memo relies heavily on notation and terms defined <a href="./rfc822">RFC 822</a> and |
| 141 |
<a href="./rfc2045">RFC 2045</a>. In particular, the syntax for the ABNF used in this memo |
| 142 |
is defined in <a href="./rfc822">RFC 822</a>, as well as many of the terminal or nonterminal |
| 143 |
symbols from <a href="./rfc822">RFC 822</a> are used in the grammar for the header |
| 144 |
extensions defined here. Among the symbols defined in <a href="./rfc822">RFC 822</a> and |
| 145 |
referenced in this memo are: 'addr-spec', 'atom', 'CHAR', 'comment', |
| 146 |
'CTLs', 'ctext', 'linear-white-space', 'phrase', 'quoted-pair'. |
| 147 |
'quoted-string', 'SPACE', and 'word'. Successful implementation of |
| 148 |
this protocol extension requires careful attention to the <a href="./rfc822">RFC 822</a> |
| 149 |
definitions of these terms. |
| 150 |
|
| 151 |
When the term "ASCII" appears in this memo, it refers to the "7-Bit |
| 152 |
American Standard Code for Information Interchange", ANSI X3.4-1986. |
| 153 |
The MIME charset name for this character set is "US-ASCII". When not |
| 154 |
specifically referring to the MIME charset name, this document uses |
| 155 |
the term "ASCII", both for brevity and for consistency with <a href="./rfc822">RFC 822</a>. |
| 156 |
However, implementors are warned that the character set name must be |
| 157 |
spelled "US-ASCII" in MIME message and body part headers. |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
<span class="grey">Moore Standards Track [Page 3]</span></pre> |
| 165 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span> |
| 166 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 167 |
|
| 168 |
|
| 169 |
This memo specifies a protocol for the representation of non-ASCII |
| 170 |
text in message headers. It specifically DOES NOT define any |
| 171 |
translation between "8-bit headers" and pure ASCII headers, nor is |
| 172 |
any such translation assumed to be possible. |
| 173 |
|
| 174 |
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Syntax of encoded-words</span> |
| 175 |
|
| 176 |
An 'encoded-word' is defined by the following ABNF grammar. The |
| 177 |
notation of <a href="./rfc822">RFC 822</a> is used, with the exception that white space |
| 178 |
characters MUST NOT appear between components of an 'encoded-word'. |
| 179 |
|
| 180 |
encoded-word = "=?" charset "?" encoding "?" encoded-text "?=" |
| 181 |
|
| 182 |
charset = token ; see <a href="#section-3">section 3</a> |
| 183 |
|
| 184 |
encoding = token ; see <a href="#section-4">section 4</a> |
| 185 |
|
| 186 |
token = 1*<Any CHAR except SPACE, CTLs, and especials> |
| 187 |
|
| 188 |
especials = "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / " |
| 189 |
<"> / "/" / "[" / "]" / "?" / "." / "=" |
| 190 |
|
| 191 |
encoded-text = 1*<Any printable ASCII character other than "?" |
| 192 |
or SPACE> |
| 193 |
; (but see "Use of encoded-words in message |
| 194 |
; headers", <a href="#section-5">section 5</a>) |
| 195 |
|
| 196 |
Both 'encoding' and 'charset' names are case-independent. Thus the |
| 197 |
charset name "ISO-8859-1" is equivalent to "iso-8859-1", and the |
| 198 |
encoding named "Q" may be spelled either "Q" or "q". |
| 199 |
|
| 200 |
An 'encoded-word' may not be more than 75 characters long, including |
| 201 |
'charset', 'encoding', 'encoded-text', and delimiters. If it is |
| 202 |
desirable to encode more text than will fit in an 'encoded-word' of |
| 203 |
75 characters, multiple 'encoded-word's (separated by CRLF SPACE) may |
| 204 |
be used. |
| 205 |
|
| 206 |
While there is no limit to the length of a multiple-line header |
| 207 |
field, each line of a header field that contains one or more |
| 208 |
'encoded-word's is limited to 76 characters. |
| 209 |
|
| 210 |
The length restrictions are included both to ease interoperability |
| 211 |
through internetwork mail gateways, and to impose a limit on the |
| 212 |
amount of lookahead a header parser must employ (while looking for a |
| 213 |
final ?= delimiter) before it can decide whether a token is an |
| 214 |
"encoded-word" or something else. |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
<span class="grey">Moore Standards Track [Page 4]</span></pre> |
| 221 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span> |
| 222 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 223 |
|
| 224 |
|
| 225 |
IMPORTANT: 'encoded-word's are designed to be recognized as 'atom's |
| 226 |
by an <a href="./rfc822">RFC 822</a> parser. As a consequence, unencoded white space |
| 227 |
characters (such as SPACE and HTAB) are FORBIDDEN within an |
| 228 |
'encoded-word'. For example, the character sequence |
| 229 |
|
| 230 |
=?iso-8859-1?q?this is some text?= |
| 231 |
|
| 232 |
would be parsed as four 'atom's, rather than as a single 'atom' (by |
| 233 |
an <a href="./rfc822">RFC 822</a> parser) or 'encoded-word' (by a parser which understands |
| 234 |
'encoded-words'). The correct way to encode the string "this is some |
| 235 |
text" is to encode the SPACE characters as well, e.g. |
| 236 |
|
| 237 |
=?iso-8859-1?q?this=20is=20some=20text?= |
| 238 |
|
| 239 |
The characters which may appear in 'encoded-text' are further |
| 240 |
restricted by the rules in <a href="#section-5">section 5</a>. |
| 241 |
|
| 242 |
<span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. Character sets</span> |
| 243 |
|
| 244 |
The 'charset' portion of an 'encoded-word' specifies the character |
| 245 |
set associated with the unencoded text. A 'charset' can be any of |
| 246 |
the character set names allowed in an MIME "charset" parameter of a |
| 247 |
"text/plain" body part, or any character set name registered with |
| 248 |
IANA for use with the MIME text/plain content-type. |
| 249 |
|
| 250 |
Some character sets use code-switching techniques to switch between |
| 251 |
"ASCII mode" and other modes. If unencoded text in an 'encoded-word' |
| 252 |
contains a sequence which causes the charset interpreter to switch |
| 253 |
out of ASCII mode, it MUST contain additional control codes such that |
| 254 |
ASCII mode is again selected at the end of the 'encoded-word'. (This |
| 255 |
rule applies separately to each 'encoded-word', including adjacent |
| 256 |
'encoded-word's within a single header field.) |
| 257 |
|
| 258 |
When there is a possibility of using more than one character set to |
| 259 |
represent the text in an 'encoded-word', and in the absence of |
| 260 |
private agreements between sender and recipients of a message, it is |
| 261 |
recommended that members of the ISO-8859-* series be used in |
| 262 |
preference to other character sets. |
| 263 |
|
| 264 |
<span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. Encodings</span> |
| 265 |
|
| 266 |
Initially, the legal values for "encoding" are "Q" and "B". These |
| 267 |
encodings are described below. The "Q" encoding is recommended for |
| 268 |
use when most of the characters to be encoded are in the ASCII |
| 269 |
character set; otherwise, the "B" encoding should be used. |
| 270 |
Nevertheless, a mail reader which claims to recognize 'encoded-word's |
| 271 |
MUST be able to accept either encoding for any character set which it |
| 272 |
supports. |
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
<span class="grey">Moore Standards Track [Page 5]</span></pre> |
| 277 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span> |
| 278 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 279 |
|
| 280 |
|
| 281 |
Only a subset of the printable ASCII characters may be used in |
| 282 |
'encoded-text'. Space and tab characters are not allowed, so that |
| 283 |
the beginning and end of an 'encoded-word' are obvious. The "?" |
| 284 |
character is used within an 'encoded-word' to separate the various |
| 285 |
portions of the 'encoded-word' from one another, and thus cannot |
| 286 |
appear in the 'encoded-text' portion. Other characters are also |
| 287 |
illegal in certain contexts. For example, an 'encoded-word' in a |
| 288 |
'phrase' preceding an address in a From header field may not contain |
| 289 |
any of the "specials" defined in <a href="./rfc822">RFC 822</a>. Finally, certain other |
| 290 |
characters are disallowed in some contexts, to ensure reliability for |
| 291 |
messages that pass through internetwork mail gateways. |
| 292 |
|
| 293 |
The "B" encoding automatically meets these requirements. The "Q" |
| 294 |
encoding allows a wide range of printable characters to be used in |
| 295 |
non-critical locations in the message header (e.g., Subject), with |
| 296 |
fewer characters available for use in other locations. |
| 297 |
|
| 298 |
<span class="h3"><a class="selflink" id="section-4.1" href="#section-4.1">4.1</a>. The "B" encoding</span> |
| 299 |
|
| 300 |
The "B" encoding is identical to the "BASE64" encoding defined by <a href="./rfc2045">RFC</a> |
| 301 |
<a href="./rfc2045">2045</a>. |
| 302 |
|
| 303 |
<span class="h3"><a class="selflink" id="section-4.2" href="#section-4.2">4.2</a>. The "Q" encoding</span> |
| 304 |
|
| 305 |
The "Q" encoding is similar to the "Quoted-Printable" content- |
| 306 |
transfer-encoding defined in <a href="./rfc2045">RFC 2045</a>. It is designed to allow text |
| 307 |
containing mostly ASCII characters to be decipherable on an ASCII |
| 308 |
terminal without decoding. |
| 309 |
|
| 310 |
(1) Any 8-bit value may be represented by a "=" followed by two |
| 311 |
hexadecimal digits. For example, if the character set in use |
| 312 |
were ISO-8859-1, the "=" character would thus be encoded as |
| 313 |
"=3D", and a SPACE by "=20". (Upper case should be used for |
| 314 |
hexadecimal digits "A" through "F".) |
| 315 |
|
| 316 |
(2) The 8-bit hexadecimal value 20 (e.g., ISO-8859-1 SPACE) may be |
| 317 |
represented as "_" (underscore, ASCII 95.). (This character may |
| 318 |
not pass through some internetwork mail gateways, but its use |
| 319 |
will greatly enhance readability of "Q" encoded data with mail |
| 320 |
readers that do not support this encoding.) Note that the "_" |
| 321 |
always represents hexadecimal 20, even if the SPACE character |
| 322 |
occupies a different code position in the character set in use. |
| 323 |
|
| 324 |
(3) 8-bit values which correspond to printable ASCII characters other |
| 325 |
than "=", "?", and "_" (underscore), MAY be represented as those |
| 326 |
characters. (But see <a href="#section-5">section 5</a> for restrictions.) In |
| 327 |
particular, SPACE and TAB MUST NOT be represented as themselves |
| 328 |
within encoded words. |
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
<span class="grey">Moore Standards Track [Page 6]</span></pre> |
| 333 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span> |
| 334 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 335 |
|
| 336 |
|
| 337 |
<span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Use of encoded-words in message headers</span> |
| 338 |
|
| 339 |
An 'encoded-word' may appear in a message header or body part header |
| 340 |
according to the following rules: |
| 341 |
|
| 342 |
(1) An 'encoded-word' may replace a 'text' token (as defined by <a href="./rfc822">RFC 822</a>) |
| 343 |
in any Subject or Comments header field, any extension message |
| 344 |
header field, or any MIME body part field for which the field body |
| 345 |
is defined as '*text'. An 'encoded-word' may also appear in any |
| 346 |
user-defined ("X-") message or body part header field. |
| 347 |
|
| 348 |
Ordinary ASCII text and 'encoded-word's may appear together in the |
| 349 |
same header field. However, an 'encoded-word' that appears in a |
| 350 |
header field defined as '*text' MUST be separated from any adjacent |
| 351 |
'encoded-word' or 'text' by 'linear-white-space'. |
| 352 |
|
| 353 |
(2) An 'encoded-word' may appear within a 'comment' delimited by "(" and |
| 354 |
")", i.e., wherever a 'ctext' is allowed. More precisely, the <a href="./rfc822">RFC</a> |
| 355 |
<a href="./rfc822">822</a> ABNF definition for 'comment' is amended as follows: |
| 356 |
|
| 357 |
comment = "(" *(ctext / quoted-pair / comment / encoded-word) ")" |
| 358 |
|
| 359 |
A "Q"-encoded 'encoded-word' which appears in a 'comment' MUST NOT |
| 360 |
contain the characters "(", ")" or " |
| 361 |
'encoded-word' that appears in a 'comment' MUST be separated from |
| 362 |
any adjacent 'encoded-word' or 'ctext' by 'linear-white-space'. |
| 363 |
|
| 364 |
It is important to note that 'comment's are only recognized inside |
| 365 |
"structured" field bodies. In fields whose bodies are defined as |
| 366 |
'*text', "(" and ")" are treated as ordinary characters rather than |
| 367 |
comment delimiters, and rule (1) of this section applies. (See <a href="./rfc822">RFC</a> |
| 368 |
<a href="./rfc822">822</a>, sections <a href="#section-3.1.2">3.1.2</a> and <a href="#section-3.1.3">3.1.3</a>) |
| 369 |
|
| 370 |
(3) As a replacement for a 'word' entity within a 'phrase', for example, |
| 371 |
one that precedes an address in a From, To, or Cc header. The ABNF |
| 372 |
definition for 'phrase' from <a href="./rfc822">RFC 822</a> thus becomes: |
| 373 |
|
| 374 |
phrase = 1*( encoded-word / word ) |
| 375 |
|
| 376 |
In this case the set of characters that may be used in a "Q"-encoded |
| 377 |
'encoded-word' is restricted to: <upper and lower case ASCII |
| 378 |
letters, decimal digits, "!", "*", "+", "-", "/", "=", and "_" |
| 379 |
(underscore, ASCII 95.)>. An 'encoded-word' that appears within a |
| 380 |
'phrase' MUST be separated from any adjacent 'word', 'text' or |
| 381 |
'special' by 'linear-white-space'. |
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
<span class="grey">Moore Standards Track [Page 7]</span></pre> |
| 389 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span> |
| 390 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 391 |
|
| 392 |
|
| 393 |
These are the ONLY locations where an 'encoded-word' may appear. In |
| 394 |
particular: |
| 395 |
|
| 396 |
+ An 'encoded-word' MUST NOT appear in any portion of an 'addr-spec'. |
| 397 |
|
| 398 |
+ An 'encoded-word' MUST NOT appear within a 'quoted-string'. |
| 399 |
|
| 400 |
+ An 'encoded-word' MUST NOT be used in a Received header field. |
| 401 |
|
| 402 |
+ An 'encoded-word' MUST NOT be used in parameter of a MIME |
| 403 |
Content-Type or Content-Disposition field, or in any structured |
| 404 |
field body except within a 'comment' or 'phrase'. |
| 405 |
|
| 406 |
The 'encoded-text' in an 'encoded-word' must be self-contained; |
| 407 |
'encoded-text' MUST NOT be continued from one 'encoded-word' to |
| 408 |
another. This implies that the 'encoded-text' portion of a "B" |
| 409 |
'encoded-word' will be a multiple of 4 characters long; for a "Q" |
| 410 |
'encoded-word', any "=" character that appears in the 'encoded-text' |
| 411 |
portion will be followed by two hexadecimal characters. |
| 412 |
|
| 413 |
Each 'encoded-word' MUST encode an integral number of octets. The |
| 414 |
'encoded-text' in each 'encoded-word' must be well-formed according |
| 415 |
to the encoding specified; the 'encoded-text' may not be continued in |
| 416 |
the next 'encoded-word'. (For example, "=?charset?Q?=?= |
| 417 |
=?charset?Q?AB?=" would be illegal, because the two hex digits "AB" |
| 418 |
must follow the "=" in the same 'encoded-word'.) |
| 419 |
|
| 420 |
Each 'encoded-word' MUST represent an integral number of characters. |
| 421 |
A multi-octet character may not be split across adjacent 'encoded- |
| 422 |
word's. |
| 423 |
|
| 424 |
Only printable and white space character data should be encoded using |
| 425 |
this scheme. However, since these encoding schemes allow the |
| 426 |
encoding of arbitrary octet values, mail readers that implement this |
| 427 |
decoding should also ensure that display of the decoded data on the |
| 428 |
recipient's terminal will not cause unwanted side-effects. |
| 429 |
|
| 430 |
Use of these methods to encode non-textual data (e.g., pictures or |
| 431 |
sounds) is not defined by this memo. Use of 'encoded-word's to |
| 432 |
represent strings of purely ASCII characters is allowed, but |
| 433 |
discouraged. In rare cases it may be necessary to encode ordinary |
| 434 |
text that looks like an 'encoded-word'. |
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
<span class="grey">Moore Standards Track [Page 8]</span></pre> |
| 445 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span> |
| 446 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 447 |
|
| 448 |
|
| 449 |
<span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. Support of 'encoded-word's by mail readers</span> |
| 450 |
|
| 451 |
<span class="h3"><a class="selflink" id="section-6.1" href="#section-6.1">6.1</a>. Recognition of 'encoded-word's in message headers</span> |
| 452 |
|
| 453 |
A mail reader must parse the message and body part headers according |
| 454 |
to the rules in <a href="./rfc822">RFC 822</a> to correctly recognize 'encoded-word's. |
| 455 |
|
| 456 |
'encoded-word's are to be recognized as follows: |
| 457 |
|
| 458 |
(1) Any message or body part header field defined as '*text', or any |
| 459 |
user-defined header field, should be parsed as follows: Beginning |
| 460 |
at the start of the field-body and immediately following each |
| 461 |
occurrence of 'linear-white-space', each sequence of up to 75 |
| 462 |
printable characters (not containing any 'linear-white-space') |
| 463 |
should be examined to see if it is an 'encoded-word' according to |
| 464 |
the syntax rules in <a href="#section-2">section 2</a>. Any other sequence of printable |
| 465 |
characters should be treated as ordinary ASCII text. |
| 466 |
|
| 467 |
(2) Any header field not defined as '*text' should be parsed |
| 468 |
according to the syntax rules for that header field. However, |
| 469 |
any 'word' that appears within a 'phrase' should be treated as an |
| 470 |
'encoded-word' if it meets the syntax rules in <a href="#section-2">section 2</a>. |
| 471 |
Otherwise it should be treated as an ordinary 'word'. |
| 472 |
|
| 473 |
(3) Within a 'comment', any sequence of up to 75 printable characters |
| 474 |
(not containing 'linear-white-space'), that meets the syntax |
| 475 |
rules in <a href="#section-2">section 2</a>, should be treated as an 'encoded-word'. |
| 476 |
Otherwise it should be treated as normal comment text. |
| 477 |
|
| 478 |
(4) A MIME-Version header field is NOT required to be present for |
| 479 |
'encoded-word's to be interpreted according to this |
| 480 |
specification. One reason for this is that the mail reader is |
| 481 |
not expected to parse the entire message header before displaying |
| 482 |
lines that may contain 'encoded-word's. |
| 483 |
|
| 484 |
<span class="h3"><a class="selflink" id="section-6.2" href="#section-6.2">6.2</a>. Display of 'encoded-word's</span> |
| 485 |
|
| 486 |
Any 'encoded-word's so recognized are decoded, and if possible, the |
| 487 |
resulting unencoded text is displayed in the original character set. |
| 488 |
|
| 489 |
NOTE: Decoding and display of encoded-words occurs *after* a |
| 490 |
structured field body is parsed into tokens. It is therefore |
| 491 |
possible to hide 'special' characters in encoded-words which, when |
| 492 |
displayed, will be indistinguishable from 'special' characters in the |
| 493 |
surrounding text. For this and other reasons, it is NOT generally |
| 494 |
possible to translate a message header containing 'encoded-word's to |
| 495 |
an unencoded form which can be parsed by an <a href="./rfc822">RFC 822</a> mail reader. |
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
<span class="grey">Moore Standards Track [Page 9]</span></pre> |
| 501 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-10" ></span> |
| 502 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 503 |
|
| 504 |
|
| 505 |
When displaying a particular header field that contains multiple |
| 506 |
'encoded-word's, any 'linear-white-space' that separates a pair of |
| 507 |
adjacent 'encoded-word's is ignored. (This is to allow the use of |
| 508 |
multiple 'encoded-word's to represent long strings of unencoded text, |
| 509 |
without having to separate 'encoded-word's where spaces occur in the |
| 510 |
unencoded text.) |
| 511 |
|
| 512 |
In the event other encodings are defined in the future, and the mail |
| 513 |
reader does not support the encoding used, it may either (a) display |
| 514 |
the 'encoded-word' as ordinary text, or (b) substitute an appropriate |
| 515 |
message indicating that the text could not be decoded. |
| 516 |
|
| 517 |
If the mail reader does not support the character set used, it may |
| 518 |
(a) display the 'encoded-word' as ordinary text (i.e., as it appears |
| 519 |
in the header), (b) make a "best effort" to display using such |
| 520 |
characters as are available, or (c) substitute an appropriate message |
| 521 |
indicating that the decoded text could not be displayed. |
| 522 |
|
| 523 |
If the character set being used employs code-switching techniques, |
| 524 |
display of the encoded text implicitly begins in "ASCII mode". In |
| 525 |
addition, the mail reader must ensure that the output device is once |
| 526 |
again in "ASCII mode" after the 'encoded-word' is displayed. |
| 527 |
|
| 528 |
<span class="h3"><a class="selflink" id="section-6.3" href="#section-6.3">6.3</a>. Mail reader handling of incorrectly formed 'encoded-word's</span> |
| 529 |
|
| 530 |
It is possible that an 'encoded-word' that is legal according to the |
| 531 |
syntax defined in <a href="#section-2">section 2</a>, is incorrectly formed according to the |
| 532 |
rules for the encoding being used. For example: |
| 533 |
|
| 534 |
(1) An 'encoded-word' which contains characters which are not legal |
| 535 |
for a particular encoding (for example, a "-" in the "B" |
| 536 |
encoding, or a SPACE or HTAB in either the "B" or "Q" encoding), |
| 537 |
is incorrectly formed. |
| 538 |
|
| 539 |
(2) Any 'encoded-word' which encodes a non-integral number of |
| 540 |
characters or octets is incorrectly formed. |
| 541 |
|
| 542 |
A mail reader need not attempt to display the text associated with an |
| 543 |
'encoded-word' that is incorrectly formed. However, a mail reader |
| 544 |
MUST NOT prevent the display or handling of a message because an |
| 545 |
'encoded-word' is incorrectly formed. |
| 546 |
|
| 547 |
<span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. Conformance</span> |
| 548 |
|
| 549 |
A mail composing program claiming compliance with this specification |
| 550 |
MUST ensure that any string of non-white-space printable ASCII |
| 551 |
characters within a '*text' or '*ctext' that begins with "=?" and |
| 552 |
ends with "?=" be a valid 'encoded-word'. ("begins" means: at the |
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
<span class="grey">Moore Standards Track [Page 10]</span></pre> |
| 557 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-11" ></span> |
| 558 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 559 |
|
| 560 |
|
| 561 |
start of the field-body, immediately following 'linear-white-space', |
| 562 |
or immediately following a "(" for an 'encoded-word' within '*ctext'; |
| 563 |
"ends" means: at the end of the field-body, immediately preceding |
| 564 |
'linear-white-space', or immediately preceding a ")" for an |
| 565 |
'encoded-word' within '*ctext'.) In addition, any 'word' within a |
| 566 |
'phrase' that begins with "=?" and ends with "?=" must be a valid |
| 567 |
'encoded-word'. |
| 568 |
|
| 569 |
A mail reading program claiming compliance with this specification |
| 570 |
must be able to distinguish 'encoded-word's from 'text', 'ctext', or |
| 571 |
'word's, according to the rules in <a href="#section-6">section 6</a>, anytime they appear in |
| 572 |
appropriate places in message headers. It must support both the "B" |
| 573 |
and "Q" encodings for any character set which it supports. The |
| 574 |
program must be able to display the unencoded text if the character |
| 575 |
set is "US-ASCII". For the ISO-8859-* character sets, the mail |
| 576 |
reading program must at least be able to display the characters which |
| 577 |
are also in the ASCII set. |
| 578 |
|
| 579 |
<span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. Examples</span> |
| 580 |
|
| 581 |
The following are examples of message headers containing 'encoded- |
| 582 |
word's: |
| 583 |
|
| 584 |
From: =?US-ASCII?Q?Keith_Moore?= <[email protected]> |
| 585 |
To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <[email protected]> |
| 586 |
CC: =?ISO-8859-1?Q?Andr=E9?= Pirard <[email protected]> |
| 587 |
Subject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= |
| 588 |
=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?= |
| 589 |
|
| 590 |
Note: In the first 'encoded-word' of the Subject field above, the |
| 591 |
last "=" at the end of the 'encoded-text' is necessary because each |
| 592 |
'encoded-word' must be self-contained (the "=" character completes a |
| 593 |
group of 4 base64 characters representing 2 octets). An additional |
| 594 |
octet could have been encoded in the first 'encoded-word' (so that |
| 595 |
the encoded-word would contain an exact multiple of 3 encoded |
| 596 |
octets), except that the second 'encoded-word' uses a different |
| 597 |
'charset' than the first one. |
| 598 |
|
| 599 |
From: =?ISO-8859-1?Q?Olle_J=E4rnefors?= <[email protected]> |
| 600 |
To: [email protected], [email protected] |
| 601 |
Subject: Time for ISO 10646? |
| 602 |
|
| 603 |
To: Dave Crocker <[email protected]> |
| 604 |
Cc: [email protected], [email protected] |
| 605 |
From: =?ISO-8859-1?Q?Patrik_F=E4ltstr=F6m?= <[email protected]> |
| 606 |
Subject: Re: RFC-HDR care and feeding |
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
<span class="grey">Moore Standards Track [Page 11]</span></pre> |
| 613 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-12" ></span> |
| 614 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 615 |
|
| 616 |
|
| 617 |
From: Nathaniel Borenstein <[email protected]> |
| 618 |
(=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=) |
| 619 |
To: Greg Vaudreuil <[email protected]>, Ned Freed |
| 620 |
<[email protected]>, Keith Moore <[email protected]> |
| 621 |
Subject: Test of new header generator |
| 622 |
MIME-Version: 1.0 |
| 623 |
Content-type: text/plain; charset=ISO-8859-1 |
| 624 |
|
| 625 |
The following examples illustrate how text containing 'encoded-word's |
| 626 |
which appear in a structured field body. The rules are slightly |
| 627 |
different for fields defined as '*text' because "(" and ")" are not |
| 628 |
recognized as 'comment' delimiters. [<a href="#section-5">Section 5</a>, paragraph (1)]. |
| 629 |
|
| 630 |
In each of the following examples, if the same sequence were to occur |
| 631 |
in a '*text' field, the "displayed as" form would NOT be treated as |
| 632 |
encoded words, but be identical to the "encoded form". This is |
| 633 |
because each of the encoded-words in the following examples is |
| 634 |
adjacent to a "(" or ")" character. |
| 635 |
|
| 636 |
encoded form displayed as |
| 637 |
--------------------------------------------------------------------- |
| 638 |
(=?ISO-8859-1?Q?a?=) (a) |
| 639 |
|
| 640 |
(=?ISO-8859-1?Q?a?= b) (a b) |
| 641 |
|
| 642 |
Within a 'comment', white space MUST appear between an |
| 643 |
'encoded-word' and surrounding text. [<a href="#section-5">Section 5</a>, |
| 644 |
paragraph (2)]. However, white space is not needed between |
| 645 |
the initial "(" that begins the 'comment', and the |
| 646 |
'encoded-word'. |
| 647 |
|
| 648 |
|
| 649 |
(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=) (ab) |
| 650 |
|
| 651 |
White space between adjacent 'encoded-word's is not |
| 652 |
displayed. |
| 653 |
|
| 654 |
(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=) (ab) |
| 655 |
|
| 656 |
Even multiple SPACEs between 'encoded-word's are ignored |
| 657 |
for the purpose of display. |
| 658 |
|
| 659 |
(=?ISO-8859-1?Q?a?= (ab) |
| 660 |
=?ISO-8859-1?Q?b?=) |
| 661 |
|
| 662 |
Any amount of linear-space-white between 'encoded-word's, |
| 663 |
even if it includes a CRLF followed by one or more SPACEs, |
| 664 |
is ignored for the purposes of display. |
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
<span class="grey">Moore Standards Track [Page 12]</span></pre> |
| 669 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-13" ></span> |
| 670 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 671 |
|
| 672 |
|
| 673 |
(=?ISO-8859-1?Q?a_b?=) (a b) |
| 674 |
|
| 675 |
In order to cause a SPACE to be displayed within a portion |
| 676 |
of encoded text, the SPACE MUST be encoded as part of the |
| 677 |
'encoded-word'. |
| 678 |
|
| 679 |
(=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=) (a b) |
| 680 |
|
| 681 |
In order to cause a SPACE to be displayed between two strings |
| 682 |
of encoded text, the SPACE MAY be encoded as part of one of |
| 683 |
the 'encoded-word's. |
| 684 |
|
| 685 |
<span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. References</span> |
| 686 |
|
| 687 |
[<a id="ref-RFC 822">RFC 822</a>] Crocker, D., "Standard for the Format of ARPA Internet Text |
| 688 |
Messages", STD 11, <a href="./rfc822">RFC 822</a>, UDEL, August 1982. |
| 689 |
|
| 690 |
[<a id="ref-RFC 2049">RFC 2049</a>] Borenstein, N., and N. Freed, "Multipurpose Internet Mail |
| 691 |
Extensions (MIME) Part Five: Conformance Criteria and Examples", |
| 692 |
<a href="./rfc2049">RFC 2049</a>, November 1996. |
| 693 |
|
| 694 |
[<a id="ref-RFC 2045">RFC 2045</a>] Borenstein, N., and N. Freed, "Multipurpose Internet Mail |
| 695 |
Extensions (MIME) Part One: Format of Internet Message Bodies", |
| 696 |
<a href="./rfc2045">RFC 2045</a>, November 1996. |
| 697 |
|
| 698 |
[<a id="ref-RFC 2046">RFC 2046</a>] Borenstein N., and N. Freed, "Multipurpose Internet Mail |
| 699 |
Extensions (MIME) Part Two: Media Types", <a href="./rfc2046">RFC 2046</a>, |
| 700 |
November 1996. |
| 701 |
|
| 702 |
[<a id="ref-RFC 2048">RFC 2048</a>] Freed, N., Klensin, J., and J. Postel, "Multipurpose |
| 703 |
Internet Mail Extensions (MIME) Part Four: Registration |
| 704 |
Procedures", <a href="./rfc2048">RFC 2048</a>, November 1996. |
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
<span class="grey">Moore Standards Track [Page 13]</span></pre> |
| 725 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-14" ></span> |
| 726 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 727 |
|
| 728 |
|
| 729 |
<span class="h2"><a class="selflink" id="section-10" href="#section-10">10</a>. Security Considerations</span> |
| 730 |
|
| 731 |
Security issues are not discussed in this memo. |
| 732 |
|
| 733 |
<span class="h2"><a class="selflink" id="section-11" href="#section-11">11</a>. Acknowledgements</span> |
| 734 |
|
| 735 |
The author wishes to thank Nathaniel Borenstein, Issac Chan, Lutz |
| 736 |
Donnerhacke, Paul Eggert, Ned Freed, Andreas M. Kirchwitz, Olle |
| 737 |
Jarnefors, Mike Rosin, Yutaka Sato, Bart Schaefer, and Kazuhiko |
| 738 |
Yamamoto, for their helpful advice, insightful comments, and |
| 739 |
illuminating questions in response to earlier versions of this |
| 740 |
specification. |
| 741 |
|
| 742 |
<span class="h2"><a class="selflink" id="section-12" href="#section-12">12</a>. Author's Address</span> |
| 743 |
|
| 744 |
Keith Moore |
| 745 |
University of Tennessee |
| 746 |
107 Ayres Hall |
| 747 |
Knoxville TN 37996-1301 |
| 748 |
|
| 749 |
EMail: [email protected] |
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
<span class="grey">Moore Standards Track [Page 14]</span></pre> |
| 781 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-15" ></span> |
| 782 |
<span class="grey"><a href="./rfc2047">RFC 2047</a> Message Header Extensions November 1996</span> |
| 783 |
|
| 784 |
|
| 785 |
Appendix - changes since <a href="./rfc1522">RFC 1522</a> (in no particular order) |
| 786 |
|
| 787 |
+ explicitly state that the MIME-Version is not requried to use |
| 788 |
'encoded-word's. |
| 789 |
|
| 790 |
+ add explicit note that SPACEs and TABs are not allowed within |
| 791 |
'encoded-word's, explaining that an 'encoded-word' must look like an |
| 792 |
'atom' to an <a href="./rfc822">RFC822</a> parser.values, to be precise). |
| 793 |
|
| 794 |
+ add examples from Olle Jarnefors (thanks!) which illustrate how |
| 795 |
encoded-words with adjacent linear-white-space are displayed. |
| 796 |
|
| 797 |
+ explicitly list terms defined in <a href="./rfc822">RFC822</a> and referenced in this memo |
| 798 |
|
| 799 |
+ fix transcription typos that caused one or two lines and a couple of |
| 800 |
characters to disappear in the resulting text, due to nroff quirks. |
| 801 |
|
| 802 |
+ clarify that encoded-words are allowed in '*text' fields in both |
| 803 |
<a href="./rfc822">RFC822</a> headers and MIME body part headers, but NOT as parameter |
| 804 |
values. |
| 805 |
|
| 806 |
+ clarify the requirement to switch back to ASCII within the encoded |
| 807 |
portion of an 'encoded-word', for any charset that uses code switching |
| 808 |
sequences. |
| 809 |
|
| 810 |
+ add a note about 'encoded-word's being delimited by "(" and ")" |
| 811 |
within a comment, but not in a *text (how bizarre!). |
| 812 |
|
| 813 |
+ fix the Andre Pirard example to get rid of the trailing "_" after |
| 814 |
the =E9. (no longer needed post-1342). |
| 815 |
|
| 816 |
+ clarification: an 'encoded-word' may appear immediately following |
| 817 |
the initial "(" or immediately before the final ")" that delimits a |
| 818 |
comment, not just adjacent to "(" and ")" *within* *ctext. |
| 819 |
|
| 820 |
+ add a note to explain that a "B" 'encoded-word' will always have a |
| 821 |
multiple of 4 characters in the 'encoded-text' portion. |
| 822 |
|
| 823 |
+ add note about the "=" in the examples |
| 824 |
|
| 825 |
+ note that processing of 'encoded-word's occurs *after* parsing, and |
| 826 |
some of the implications thereof. |
| 827 |
|
| 828 |
+ explicitly state that you can't expect to translate between |
| 829 |
1522 and either vanilla 822 or so-called "8-bit headers". |
| 830 |
|
| 831 |
+ explicitly state that 'encoded-word's are not valid within a |
| 832 |
'quoted-string'. |
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
Moore Standards Track [Page 15] |
| 837 |
</pre> |