3

1 つの電子メール サービスからのヘッダーを解析できない MIME パーサーをデバッグしています。電子メール サービスには、次のように完全に次の行にあるフィールド ボディで構成されるヘッダーが含まれます。

Message-Id:
  <12345.67890.abcdef@example.com>

これは合法ですか?

RFC-822 では、有効なヘッダーについて次の文法が指定されています。

3.2.  HEADER FIELD DEFINITIONS

      These rules show a field meta-syntax, without regard for the
 particular  type  or internal syntax.  Their purpose is to permit
 detection of fields; also, they present to  higher-level  parsers
 an image of each field as fitting on one line.

 field       =  field-name ":" [ field-body ] CRLF

 field-name  =  1*<any CHAR, excluding CTLs, SPACE, and ":">

 field-body  =  field-body-contents
                [CRLF LWSP-char field-body]

 field-body-contents =
               <the ASCII characters making up the field-body, as
                defined in the following sections, and consisting
                of combinations of atom, quoted-string, and
                specials tokens, or else consisting of texts>

空の文字列は、field-body-contents を満たし、field-body の[CRLF LWSP field-body]一部を許可しますか?

4

1 に答える 1

3

はい、空白で折りたたむことは完全に許可されています。通常、これは行が長すぎる場合にのみ行われますが、とにかく完全にオプションです。折りたたむ必要も、折りたたまないようにする必要もありません。(もちろん、行が長すぎて RFC5321 に適合しない場合は、折りたたむか、何らかの方法で短くする必要があります。最近では、RFC2047 は、従来の空白の折りたたみよりも用途が広く、透過的です。)

https://www.rfc-editor.org/rfc/rfc5322#section-2.2.3で説明されているように、折り畳まれた行は 1 つの「論理行」です。(旧式の 822 は長い間新しい規格に取って代わられていることに注意してください。現在は 5322 が代替品です。)

于 2015-09-15T07:38:59.367 に答える