Quoted-Printable Mime-Words 应如何换行至正确的行长度?
我在 mime 解析库中遇到了一个 bug ,它在主题行上爆炸了包含超过一定长度的外来字符。事实证明,它会将主题转换为 Quoted-Printable MIME "Encoded-Word< /a>”,然后尝试将整个内容自动换行为 78 个字符。由于 MIME-Word 编码没有空格(它们被下划线替换),因此无法换行。
换行示例:
Subject: =?UTF-8?Q?lalalla_=E7=84=A1=E6=AD=A4=E7=84=A1=E6=AD=A4=E9=A0=85=E7=9B=AE=AE=AE=AE=AE=AE=AE=AE=AE?=
我想我可以向库贡献一个补丁以正确换行,但我找不到有关如何分解 MIME-Word 作为换行算法的一部分的参考。
RFC 5322 规定在空格处自动换行,但没有如果一串没有空格的字符超出了目标宽度,则不会提供任何有关如何操作的指导。
有人知道在这里采取正确的行动吗?
I ran into a bug in a mime parsing library where it blows up on subject lines that contain foreign characters beyond a certain length. It turns out that it would convert the subject into a Quoted-Printable MIME "Encoded-Word" and then try to word-wrap the whole thing to 78 characters. Because MIME-Word encoding has no spaces (they are replaced with underscores) it failed to wrap.
Example line being wrapped:
Subject: =?UTF-8?Q?lalalla_=E7=84=A1=E6=AD=A4=E7=84=A1=E6=AD=A4=E9=A0=85=E7=9B=AE=AE=AE=AE=AE=AE=AE=AE=AE?=
I thought I might contribute a patch to the library to wrap the line correctly but I couldn't find a reference as to how to break up a MIME-Word as part of a word-wrapping algorithm.
The RFC 5322 says to word-wrap at spaces but doesn't provide any guidance about what to do if there's a string of characters with no white-space that exceeds the target width.
Anyone know the correct action to take here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需在需要的地方分割线,然后继续第二条换行。例如:
只需确保第二个(及后续)换行以空格或制表符开头。
嗯,
——戴夫
Just split the line where you need to, and continue with a 2nd wrapped line. For example:
Just be sure to make sure the 2nd (and following) wrapped lines start with either a space or a tab.
hth,
--Dave