Skip to content

Commit

Permalink
pythongh-82530: Create blank function instead of invalid import for e…
Browse files Browse the repository at this point in the history
…mail example (python#97529)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
  • Loading branch information
slateny and terryjreedy authored Sep 26, 2022
1 parent 05c9275 commit 2b428a1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Doc/includes/email-read-alternative.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@
from email import policy
from email.parser import BytesParser

# An imaginary module that would make this work and be safe.
from imaginary import magic_html_parser

def magic_html_parser(html_text, partfiles):
"""Return safety-sanitized html linked to partfiles.
Rewrite the href="cid:...." attributes to point to the filenames in partfiles.
Though not trivial, this should be possible using html.parser.
"""
raise NotImplementedError("Add the magic needed")


# In a real program you'd get the filename from the arguments.
with open('outgoing.msg', 'rb') as fp:
Expand Down Expand Up @@ -62,9 +69,6 @@
print("Don't know how to display {}".format(richest.get_content_type()))
sys.exit()
with tempfile.NamedTemporaryFile(mode='w', delete=False) as f:
# The magic_html_parser has to rewrite the href="cid:...." attributes to
# point to the filenames in partfiles. It also has to do a safety-sanitize
# of the html. It could be written using html.parser.
f.write(magic_html_parser(body.get_content(), partfiles))
webbrowser.open(f.name)
os.remove(f.name)
Expand Down

0 comments on commit 2b428a1

Please sign in to comment.