]> git.madduck.net Git - etc/mutt.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

implement attachment check as sendmail check
authormartin f. krafft <madduck@madduck.net>
Tue, 15 Jun 2010 11:37:09 +0000 (13:37 +0200)
committermartin f. krafft <madduck@madduck.net>
Tue, 15 Jun 2010 11:37:09 +0000 (13:37 +0200)
.mutt/sendmail-checks.d/check-attachments [new file with mode: 0755]

diff --git a/.mutt/sendmail-checks.d/check-attachments b/.mutt/sendmail-checks.d/check-attachments
new file mode 100755 (executable)
index 0000000..760822d
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# check-attachments — check that referenced attachments are actually attached
+#
+# This is based on the idea behind
+# http://www.vim.org/scripts/download_script.php?src_id=3165: if the mail body
+# matches a given regular expression, then check whether there are also
+# non-PGP MIME parts in the message, or else refuse to send the message.
+#
+# You can override the checking by adding the X-No-Attachments header to the
+# message.
+#
+# Copyright © 2010 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+set -eu
+
+RE_ENGLISH='attach(ing|ed|ment)?|included\W+(with|in)\W+th(is|e\W+(curr|pres)ent)\W+mail'
+RE_GERMAN='an(gehängt|hängsel|bei)|bei(gefügt|lage)|(im|siehe)\W+(anhang|beilage)'
+RE_FRENCH='attach(e|er|ée?s?|ement|ant)'
+OVERRIDE_HEADER=X-No-Attachments
+
+if ! grep -q "^${OVERRIDE_HEADER}:" "$1" \
+     && egrep -ziq "($RE_ENGLISH|$RE_GERMAN|$RE_FRENCH)" "$1"; then
+
+  nr_attach=$(sed -rne 's/^Content-Type:[[:space:]]+//p' "$1" |
+              egrep -cv '^(multipart/|application/pgp-signature)')
+
+  if [ $nr_attach -lt 2 ]; then
+    echo >&2 "E: the mail seems to reference an attachment, but there seems"
+    echo >&2 "to be no non-PGP MIME part."
+    echo >&2 "E: (add the $OVERRIDE_HEADER header to override the check)."
+    exit 1
+  fi
+fi