mime.quotedprintable无法解码此消息。

huangapple go评论92阅读模式
英文:

mime.quotedprintable having trouble decoding this message

问题

我正在尝试解码一条消息,该消息不完全符合“Quoted Printable String”的规范。

下面的代码片段中,有一个=应该是=3D,这在多个地方都出现了。实际上,这里发生了两个错误:

------=_Part_7575500_2105086112.1449628640342
Content-Type: text/html; charset="UTF-8"

我使用以下代码进行解码:

qpr := quotedprintable.NewReader(msg.Body)
	cleanBody, err := ioutil.ReadAll(qpr)

结果出现错误:(在第一个=之后出现了下划线)

quotedprintable: invalid hex byte 0x5f

请问我该如何修复这个问题?谢谢。

英文:

I am trying to decode a message which doesn't completely conform to the Quoted Printable String idea.

One of the snippets as shown below has an = where should be an =3D this occurs in a number of places. In fact there are two offences occurring here:

------=_Part_7575500_2105086112.1449628640342
Content-Type: text/html; charset="UTF-8"

I'm decoding with the as follows:

qpr := quotedprintable.NewReader(msg.Body)
	cleanBody, err := ioutil.ReadAll(qpr)

The resulting error is: (complaining about the _ after first =)

quotedprintable: invalid hex byte 0x5f

How can I fix get this to work please? Thank you.

答案1

得分: 0

你不仅仅有 quoted-printable 数据,它还是 MIME 多部分消息的一部分。=_ 模式的使用是因为它在 quoted-printable 消息中永远不会出现。

使用 multipart.Reader 来获取每个部分的内容。

英文:

You don't just have quoted-printable data, it's part of a MIME multipart message. The =_ pattern is specifically used because it can never occur in a quoted-printable message.

Use a multipart.Reader to get the contents of each part.

huangapple
  • 本文由 发表于 2015年12月12日 00:05:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/34227760.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定