[PATCH] fix(nmweb): replace deprecated method

Subject: [PATCH] fix(nmweb): replace deprecated method

Date: Mon, 25 Oct 2021 20:22:52 -0400

To: notmuch@notmuchmail.org

Cc: Austin Ray

From: Austin Ray


Python 3.2 deprecated 'cgi.escape()' and Python 3.8 removed it[1][2].
Its replacement is 'html.escape()'.

[0] https://docs.python.org/3.7/library/cgi.html#cgi.escape
[1] https://docs.python.org/3/whatsnew/3.8.html#api-and-feature-removals
[2] https://bugs.python.org/issue33843

Signed-off-by: Austin Ray <austin@austinray.io>
---
 contrib/notmuch-web/nmweb.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/notmuch-web/nmweb.py b/contrib/notmuch-web/nmweb.py
index 9e337436..0754a502 100755
--- a/contrib/notmuch-web/nmweb.py
+++ b/contrib/notmuch-web/nmweb.py
@@ -14,7 +14,7 @@ from mailbox import MaildirMessage
 import mimetypes
 import email
 import re
-import cgi
+import html
 import os
 
 import bleach
@@ -265,7 +265,7 @@ def format_message_walk(msg, mid):
         yield '<pre>'
         out = part.get_payload(decode=True)
         out = decodeAnyway(out, part.get_content_charset('ascii'))
-        out = cgi.escape(out)
+        out = html.escape(out)
         out = out.encode('ascii', 'xmlcharrefreplace').decode('ascii')
         if linkify_plaintext: out = bleach.linkify(out, callbacks=[require_protocol_prefix])
         yield out
-- 
2.32.0

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: