File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 8
8
from email import policy
9
9
from email .parser import BytesParser
10
10
11
- # An imaginary module that would make this work and be safe.
12
- from imaginary import magic_html_parser
11
+
12
+ def magic_html_parser (html_text , partfiles ):
13
+ """Return safety-sanitized html linked to partfiles.
14
+
15
+ Rewrite the href="cid:...." attributes to point to the filenames in partfiles.
16
+ Though not trivial, this should be possible using html.parser.
17
+ """
18
+ raise NotImplementedError ("Add the magic needed" )
19
+
13
20
14
21
# In a real program you'd get the filename from the arguments.
15
22
with open ('outgoing.msg' , 'rb' ) as fp :
62
69
print ("Don't know how to display {}" .format (richest .get_content_type ()))
63
70
sys .exit ()
64
71
with tempfile .NamedTemporaryFile (mode = 'w' , delete = False ) as f :
65
- # The magic_html_parser has to rewrite the href="cid:...." attributes to
66
- # point to the filenames in partfiles. It also has to do a safety-sanitize
67
- # of the html. It could be written using html.parser.
68
72
f .write (magic_html_parser (body .get_content (), partfiles ))
69
73
webbrowser .open (f .name )
70
74
os .remove (f .name )
You can’t perform that action at this time.
0 commit comments