Skip to content

Commit 8bdaf9b

Browse files
gh-82530: Create blank function instead of invalid import for email example (GH-97529)
Co-authored-by: Terry Jan Reedy <[email protected]> (cherry picked from commit 2b428a1) Co-authored-by: Stanley <[email protected]>
1 parent 96f8d36 commit 8bdaf9b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Doc/includes/email-read-alternative.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@
88
from email import policy
99
from 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.
1522
with open('outgoing.msg', 'rb') as fp:
@@ -62,9 +69,6 @@
6269
print("Don't know how to display {}".format(richest.get_content_type()))
6370
sys.exit()
6471
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.
6872
f.write(magic_html_parser(body.get_content(), partfiles))
6973
webbrowser.open(f.name)
7074
os.remove(f.name)

0 commit comments

Comments
 (0)