summaryrefslogtreecommitdiff
path: root/alot/commands/globals.py
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-01-26 12:19:54 +0100
committerAnton Khirnov <anton@khirnov.net>2021-01-26 12:20:38 +0100
commite688d4876a761f9c89e427e9c451fd2968123909 (patch)
treeaa2da896d7536df1a08064b6d2fe340515d68471 /alot/commands/globals.py
parent13cba7ad0bfcbb8eacfffaf1913d11897c8f91c2 (diff)
ComposeCommand: read template/signature as text
We should not try to guess anything, just use the platform encoding. Remove helper.try_decode(), as it has no more callers.
Diffstat (limited to 'alot/commands/globals.py')
-rw-r--r--alot/commands/globals.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index 310a59db..b95d37b9 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -743,8 +743,8 @@ class ComposeCommand(Command):
priority='error')
raise self.ApplyError()
try:
- with open(path, 'rb') as f:
- template = helper.try_decode(f.read())
+ with open(path, 'r') as f:
+ template = f.read()
self.envelope.parse_template(template)
except Exception as e:
ui.notify(str(e), priority='error')
@@ -804,11 +804,12 @@ class ComposeCommand(Command):
self.envelope.attach(sig, filename=name)
logging.debug('attached')
else:
- with open(sig, 'rb') as f:
- sigcontent = f.read()
- mimetype = helper.guess_mimetype(sigcontent)
- if mimetype.startswith('text'):
- sigcontent = helper.try_decode(sigcontent)
+ try:
+ with open(sig, 'r') as f:
+ sigcontent = f.read()
+ except UnicodeDecodeError:
+ ui.notify('Could not read signature', priority = 'error')
+ else:
self.envelope.body += '\n' + sigcontent
else:
ui.notify('could not locate signature: %s' % sig,