Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANSI codes in replies to HTML mails #1531

Open
mjg opened this issue Jun 21, 2020 · 6 comments
Open

ANSI codes in replies to HTML mails #1531

mjg opened this issue Jun 21, 2020 · 6 comments

Comments

@mjg
Copy link
Contributor

mjg commented Jun 21, 2020

Describe the bug
Replying to HTML messages produces ANSI codes

Software Versions

  • Python version: 3.7.7
  • Notmuch version: 0.29
  • Alot version: 530addc

To Reproduce
Steps to reproduce the behaviour:

  1. Use the suggested text/html-entry in mailcap (elinks) to produce ANSI codes
  2. reply to HTML message
  3. observe the quoted text:
XYZ venit, vidit, dixit 2020-06-21 14:26:49:
> ^[[38;5;0m^[[48;5;0m^[[38;5;15m   ^[[38;5;250mLieber Herr Gruber,

I might be missing some additional config to convert ANSIfied HTML back to txt or so, but ANSIfied bofy text certainly is not intended to be quoted in replies as is.

@pazz
Copy link
Owner

pazz commented Jun 22, 2020 via email

@johslarsen
Copy link
Contributor

johslarsen commented Jul 7, 2020

I have the same problem. My far from perfect, but still usable workaround is to strip away ANSI escape codes in the hook for quoting text. This can be achieved with a hook like:

ANSI_ESCAPE = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/ ]*[@-~])')
def text_quote(message):
  ANSI_ESCAPE.sub('', message)

@mjg
Copy link
Contributor Author

mjg commented Jul 8, 2020

Thanks for the hint.

My workaround is to avoid the feature alltogether since interpret_ansi_background = false does not catch those cases where some combination of stupid styles and elinks mode produces blinking text (for the whole e-mail body), which is completely nuts. Yes, I know this is foreground, but for me there are too many issues (startup performance, blinking foreground, escapes in replies) with ANSItext and too little time to hunt them down (in config or code).

I'm just wondering if there's anyone not having a problem with replies to HTML e-mails when using ANSI conversion - this appears to be by design, not by coincidence in specific configurations.

@pazz
Copy link
Owner

pazz commented Jul 8, 2020 via email

@aplund
Copy link

aplund commented Feb 28, 2021

Shouldn't the mailcap 'compose' field be used to specify how to format the text correctly?

@pazz
Copy link
Owner

pazz commented Mar 29, 2021

@aplund I've never heard of that one, but yes, it looks like we should be respecting that. PRs welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants