Commit b430c78e authored by Siltaar's avatar Siltaar

fix occurence of html entities in rewritten emails

parent e48841f7
......@@ -10,11 +10,13 @@ from email.iterators import _structure # noqa
from sys import stdin, stderr, argv
from difflib import SequenceMatcher
from re import DOTALL, compile as compile_re
from html import unescape
purge_html_re = compile_re( # match, to remove :
b'<(sty|(o|w):|scr|tit|[^y]*y\s*:\s*(n|h)).*?</[^>]*'
# style, o: w:, script, title, display:none / hidden HTML tags, text leaf, partial ending
# '<(sty|(o|w):|scr|tit|[^y]*yle="display\s*:\s*(n|h)).*?</[^>]*'
b'|<!--.*?-->' # HTML comments
b'|<[^>]*' # all complete HTML tags, # some may be cut at the end/begining
b'|&[^;]*;' # HTML entities
......@@ -138,8 +140,8 @@ def are_idem_txt(part_txt, part_htm):
from shutil import get_terminal_size
ir = ' '+color_ratio(idem_ratio)
cols, rows = get_terminal_size()
PUT_txt = int(cols) - 8
PUT_htm = int(cols) - 7
PUT_txt = int(cols) - 10
PUT_htm = int(cols) - 9
def put(string, postfix, size):
print(string[:size].ljust(size, '.') + postfix, file=stderr)
......@@ -205,4 +207,4 @@ if __name__ == "__main__":
input_eml = stdin.buffer.raw.read() # separate lines to allow debugging
output_eml = drop_alternatives(input_eml)
str_eml = str(output_eml.as_bytes(), errors='replace')
print(str_eml, end='')
print(unescape(str_eml), end='')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment