X-Git-Url: https://projects.mako.cc/source/attachcheck/blobdiff_plain/6365b7fdcfabce5f929e2608deaab73bd3989142..786be57db0813f999af2454536121a8c3b3d82ee:/attachcheck diff --git a/attachcheck b/attachcheck index 5864de0..e633291 100755 --- a/attachcheck +++ b/attachcheck @@ -35,8 +35,10 @@ 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)' ] + r'\balleg(o|at[oaie]|ando)(?im)' ] +# ignore quoted text (which might refer to attachments in previous emails) +attachment_regexes = [ r'(^|^[^\n>].*)' + x for x in attachment_regexes ] ### No Edit Below This Line ########################################### @@ -50,11 +52,17 @@ import re def send_message(): global sendmail - sendmail = sendmail + " " + " ".join( sys.argv[1:] ) - - mailpipe = os.popen("%s" % sendmail, 'w') + + # construct the sendmail pipe more safely (thanks iain murray!) + cmd = sys.argv[:] + cmd[0] = sendmail + + from subprocess import Popen, PIPE + process = Popen(cmd, stdin=PIPE) + mailpipe = process.stdin mailpipe.write( message_string ) - sys.exit( mailpipe.close() ) + mailpipe.close() + sys.exit( process.wait() ) ## SUB: print error message def print_error():