3

虽然RFC 2045明确指出,quoted-printable (QP) 中的一行不得超过 76 个字符,但在现实世界中,并非每个客户端似乎都遵循此要求。还是我误解了 RFC 的要求?

考虑来自真实世界邮件的以下几行:

<style type=3D"text/css">=0Abody,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }=0A</style>=0A<body style=3D"background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sa=
ns-serif; font-size:12px; margin:0; padding:0;">=0D=0A<div style=3D"background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">=0D=0A<table cellspacin=
g=3D"0" cellpadding=3D"0" border=3D"0" width=3D"100%">=0D=0A<tr>=0D=0A    <td align=3D"center" valign=3D"top" style=3D"padding:20px 0 20px 0">=0D=0A        <!-- [ header starts here] -->=0D=0A       =

每行是 201 个字符加上 CRLF。但是,有几个=0A序列可以转换为 LF。那么这是否意味着我需要能够解析此消息或者我可以拒绝它?

在我看来,它违反了 RFC 中的以下声明,但我不是 100% 确定:

(5)   (Soft Line Breaks) The Quoted-Printable encoding
      REQUIRES that encoded lines be no more than 76
      characters long.  If longer lines are to be encoded
      with the Quoted-Printable encoding, "soft" line breaks
      must be used.  An equal sign as the last character on a
      encoded line indicates such a non-significant ("soft")
      line break in the encoded text.
4

1 回答 1

3

尽管最长的行包含 128 个符号,但您应该能够解析此消息。

此消息中有=0A=SPACE序列。
=0A是一个有意义的换行符,=SPACE是一个软换行符。
硬换行符应该是 CRLF ( =0D=0A) 但链接的 RFC 2045
也只允许 LF(没有 CR):

(4)   (Line Breaks) A line break in a text body, represented
      as a CRLF sequence in the text canonical form, must be
      represented by a (RFC 822) line break, which is also a
      CRLF sequence, in the Quoted-Printable encoding.  (...)

      Note that many implementations may elect to encode the
      local representation of various content types directly
      rather than converting to canonical form first,
      encoding, and then converting back to local
      representation.  In particular, this may apply to plain
      text material on systems that use newline conventions
      other than a CRLF terminator sequence.  Such an
      implementation optimization is permissible, but only
      when the combined canonicalization-encoding step is
      equivalent to performing the three steps separately.
于 2014-09-27T19:12:48.100 回答