updated attachcheck to work with python 3.11
authorBenjamin Mako Hill <mako@atdot.cc>
Thu, 13 Apr 2023 21:09:00 +0000 (14:09 -0700)
committerBenjamin Mako Hill <mako@atdot.cc>
Thu, 13 Apr 2023 21:09:00 +0000 (14:09 -0700)
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

index 5580a32ca68a9d835f7c72d6641041499006da90..86f110aeaa6cae27c3b2819fee42a77e997da699 100755 (executable)
@@ -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
 

Benjamin Mako Hill || Want to submit a patch?