[PATCH] mail: encode long unicode lines in emails properly (issue5687)

Yuya Nishihara yuya at tcha.org
Mon Sep 25 11:13:14 EDT 2017


On Mon, 25 Sep 2017 16:50:33 +0300, Igor Ippolitov wrote:
> There is a nice small research from Django which states that QP is
> preferred for UTF8 texts: https://code.djangoproject.com/ticket/22561
> Base64 is preferred for binary data.

Okay, then we might want to use QP no matter if there is a long line.

> Concerning the "if enc: ... else:" part, I thought you don't have to encode
> long lines on your own. But this is still an issue.

Yeah, there is still a long lines issue, but we've enforce the QP encoding
in that case. My question is why can't we rely on the email module to encode
the payload according to the specified charset?

  if long:
      # don't: body = quopri.encodestring(body)
      cs.body_encoding = QP
  else:
      # use the default body_encoding: None, QP or BASE64
  msg.set_payload(body, cs)

> So this part should be as it is.
> 'set_charset' call sets correct headers for a letter (not only
> 'Content-Transfer-Encoding')
> This call will change payload if no CTE header is set. So for preencoded
> payload it is called before payload is set. If it is called after - the
> payload will be double encoded (like it is now for long unicode lines).


More information about the Mercurial-devel mailing list