From ec0cb0c5badb29607e954015809a739bcfa4beec Mon Sep 17 00:00:00 2001 From: Benjamin Mako Hill Date: Thu, 13 Apr 2023 14:09:00 -0700 Subject: [PATCH] updated attachcheck to work with python 3.11 seems like any regex that uses global options needs to move them to the beginning of the regex now. this affected 3 regexes in attachcheck --- attachcheck | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/attachcheck b/attachcheck index 5580a32..86f110a 100755 --- a/attachcheck +++ b/attachcheck @@ -34,8 +34,8 @@ ignored_types = ( "applica/pgp-signat", "application/pgp-signature" ) # list of regular expressions which we will view as being indicative # of an attachment -attachment_regexes = [ r'\battach(ed|ment|ing)?\b(?im)', - r'\balleg(o|at[oaie]|ando)(?im)' ] +attachment_regexes = [ r'(?im)\battach(ed|ment|ing)?\b', + r'(?im)\balleg(o|at[oaie]|ando)' ] # ignore quoted text (which might refer to attachments in previous emails) attachment_regexes = [ r'(^|^[^\n>].*)' + x for x in attachment_regexes ] @@ -109,8 +109,8 @@ for part in message.walk(): attachment_expected = True # check to see if this mime-type is something we can ignore - elif ( re.match( r'message/(?m)', part.get_content_type() ) or - re.match( r'multipart/(?m)', part.get_content_type() ) or + elif ( re.match( r'(?m)message/', part.get_content_type() ) or + re.match( r'(?m)multipart/', part.get_content_type() ) or part.get_content_type() in ignored_types ): continue -- 2.30.2