Skip to content

Commit

Permalink
commands/thread: Filter out ANSI CSI when replying
Browse files Browse the repository at this point in the history
It is undesirable to have those sequence in the quoted text of a reply
message. Remove them.
  • Loading branch information
guludo committed Apr 6, 2023
1 parent 6455d81 commit 6efa797
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions alot/commands/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from ..helper import parse_mailcap_nametemplate
from ..helper import split_commandstring
from ..utils import argparse as cargparse
from ..utils import ansi
from ..widgets.globals import AttachmentWidget

MODE = 'thread'
Expand Down Expand Up @@ -149,11 +150,12 @@ async def apply(self, ui):
quotestring = 'Quoting %s (%s)\n' % (name or address, timestamp)
mailcontent = quotestring
quotehook = settings.get_hook('text_quote')
body_text = ansi.remove_csi(self.message.get_body_text())
if quotehook:
mailcontent += quotehook(self.message.get_body_text())
mailcontent += quotehook(body_text)
else:
quote_prefix = settings.get('quote_prefix')
for line in self.message.get_body_text().splitlines():
for line in body_text.splitlines():
mailcontent += quote_prefix + line + '\n'

envelope = Envelope(bodytext=mailcontent, replied=self.message)
Expand Down

0 comments on commit 6efa797

Please sign in to comment.