File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 88from email import policy
99from email .parser import BytesParser
1010
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+
1320
1421# In a real program you'd get the filename from the arguments.
1522with open ('outgoing.msg' , 'rb' ) as fp :
6269 print ("Don't know how to display {}" .format (richest .get_content_type ()))
6370 sys .exit ()
6471with 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.
6872 f .write (magic_html_parser (body .get_content (), partfiles ))
6973webbrowser .open (f .name )
7074os .remove (f .name )
You can’t perform that action at this time.
0 commit comments