From: Benjamin Mako Hill Date: Thu, 13 Apr 2023 21:09:00 +0000 (-0700) Subject: updated attachcheck to work with python 3.11 X-Git-Url: https://projects.mako.cc/source/attachcheck/commitdiff_plain/ec0cb0c5badb29607e954015809a739bcfa4beec?ds=sidebyside 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 --- 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