All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
3 # check-attachments — check that referenced attachments are actually attached
5 # This is based on the idea behind
6 # http://www.vim.org/scripts/download_script.php?src_id=3165: if the mail body
7 # matches a given regular expression, then check whether there are also
8 # non-PGP MIME parts in the message, or else refuse to send the message.
10 # You can override the checking by adding the X-No-Attachments header to the
13 # Copyright © 2010 martin f. krafft <madduck@madduck.net>
14 # Released under the terms of the Artistic Licence 2.0
18 RE_ENGLISH='attach(ing|ed|ment)?|included\W+(with|in)\W+th(is|e\W+(curr|pres)ent)\W+mail'
19 RE_GERMAN='an(gehängt|hängsel|bei)|bei(gefügt|lage)|(im|siehe)\W+(anhang|beilage)'
20 RE_FRENCH='attach(e|er|ée?s?|ement|ant)'
21 OVERRIDE_HEADER=X-No-Attachments
23 if ! grep -q "^${OVERRIDE_HEADER}:" "$1" \
24 && egrep -ziq "($RE_ENGLISH|$RE_GERMAN|$RE_FRENCH)" "$1"; then
26 nr_attach=$(sed -rne 's/^Content-Type:[[:space:]]+//p' "$1" |
27 egrep -cv '^(multipart/|application/pgp-signature)')
29 if [ $nr_attach -lt 2 ]; then
30 echo >&2 "E: the mail seems to reference an attachment, but there seems"
31 echo >&2 "to be no non-PGP MIME part."
32 echo >&2 "E: (add the $OVERRIDE_HEADER header to override the check)."