Quoted-Printable Mime-Words 应如何换行至正确的行长度?

发布于 2024-12-16 02:04:36 字数 739 浏览 0 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天涯离梦残月幽梦 2024-12-23 02:04:36

只需在需要的地方分割线,然后继续第二条换行。例如:

Subject: =?UTF-8?Q?lalalla_=E7=84=A1=E6=AD=A4=E7=84=A1=E6=AD=A4?=
 =?UTF-8?Q?=E9=A0=85=E7=9B=AE=AE=AE=AE=AE=AE=AE=AE=AE?=

只需确保第二个(及后续)换行以空格或制表符开头。

嗯,
——戴夫

Just split the line where you need to, and continue with a 2nd wrapped line. For example:

Subject: =?UTF-8?Q?lalalla_=E7=84=A1=E6=AD=A4=E7=84=A1=E6=AD=A4?=
 =?UTF-8?Q?=E9=A0=85=E7=9B=AE=AE=AE=AE=AE=AE=AE=AE=AE?=

Just be sure to make sure the 2nd (and following) wrapped lines start with either a space or a tab.

hth,
--Dave

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文