summaryrefslogtreecommitdiff
path: root/alot/commands/thread.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2019-05-27 14:27:41 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2019-06-02 14:39:15 +0100
commit9b75fec97b4ad23178a730623ba691fbe666a747 (patch)
tree706974c080126042a2ce37399e15569e9dc7c824 /alot/commands/thread.py
parent553ec461d0d77e899ae51ca67ce425b5e280d1e7 (diff)
fix formataddr
This adds a local utility function `formataddr` which acts as the direct inverse of `email.utils.parseaddr`. The problem with `email.utils.formataddr` is (currently) that - it encodes non-ascii characters and - it does not re-introduce quotes around the real name parts in case parseaddr removed them: >>>parseaddr('"Ö, Ä" <a@b.c>') >>>('Ö, Ä', 'a@b.c') >>>formataddr(('Ö, Ä', 'a@b.c')) >>>'=?utf-8?q?=C3=96=2C_=C3=84?= <a@b.c>' >>>parseaddr('=?utf-8?q?=C3=96=2C_=C3=84?= <a@b.c>') >>>('=?utf-8?q?=C3=96=2C_=C3=84?=', 'a@b.c') related issue #1402
Diffstat (limited to 'alot/commands/thread.py')
-rw-r--r--alot/commands/thread.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index e3c15b2e..c4ece713 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -10,7 +10,7 @@ import subprocess
import tempfile
import email
import email.policy
-from email.utils import getaddresses, parseaddr, formataddr
+from email.utils import getaddresses, parseaddr
from email.message import Message
import urwid
@@ -26,6 +26,7 @@ from .common import RetagPromptCommand
from .envelope import SendCommand
from ..completion import ContactsCompleter, PathCompleter
from ..db.utils import decode_header
+from ..db.utils import formataddr
from ..db.utils import extract_headers
from ..db.utils import extract_body
from ..db.envelope import Envelope