Your message dated Sat, 31 Jan 2009 22:54:32 +0000
with message-id <[email protected]>
and subject line mutt: patch for idiot-proofing with attachments
has caused the Debian Bug report #182069,
regarding mutt: patch for idiot-proofing with attachments
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)
--
182069: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=182069
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: mutt
Version: 1.5.3-3
Severity: wishlist
Tags: patch
This patch checks if the body of an email contains a magic
configurable keyword (default is "attach"), and if so, checks if
there really are any attachments, and if not, alerts the user. This
is to stop the abundance of "Please find attached" ... "Oops, here
tis" emails.
The default setting (abort_noattach) is ask/yes. Setting this to "no",
would turn off this sanity check, as if the patch were never there (this
may be preferable), which may be more preferable - so to use it you need
to explictly enable it.
Patch attached. (No, really! It is! ;)
It drops cleanly into debian/patches in 1.5.3-3.
diff -ur mutt-1.5.3.orig/globals.h mutt-1.5.3/globals.h
--- mutt-1.5.3.orig/globals.h 2002-09-10 04:05:44.000000000 +0800
+++ mutt-1.5.3/globals.h 2003-02-23 02:53:21.000000000 +0800
@@ -32,6 +32,7 @@
WHERE char *AliasFile;
WHERE char *AliasFmt;
+WHERE char *AttachKeyword;
WHERE char *AttachSep;
WHERE char *Attribution;
WHERE char *AttachFormat;
diff -ur mutt-1.5.3.orig/init.h mutt-1.5.3/init.h
--- mutt-1.5.3.orig/init.h 2002-12-10 02:09:21.000000000 +0800
+++ mutt-1.5.3/init.h 2003-02-23 02:53:21.000000000 +0800
@@ -107,6 +107,14 @@
struct option_t MuttVars[] = {
/*++*/
+ { "abort_noattach", DT_QUAD, R_NONE, OPT_ATTACH, M_ASKYES },
+ /*
+ ** .pp
+ ** If set to \fIyes\fP, when composing messages containing the word
+ ** specified by $attach_keyword (default is "attach") and no attachments
+ ** are given, composition will be aborted. If set to \fIno\fP, composing
+ ** messages as such will never be aborted.
+ */
{ "abort_nosubject", DT_QUAD, R_NONE, OPT_SUBJECT, M_ASKYES },
/*
** .pp
@@ -222,6 +230,13 @@
** .dt %|X .dd pad to the end of the line with character "X"
** .de
*/
+ { "attach_keyword", DT_STR, R_NONE, UL &AttachKeyword, UL "attach" },
+ /*
+ ** .pp
+ ** If $abort_attach is not set to no, then the body of the message
+ ** will be scanned for this keyword, and if found, you will be prompted
+ ** if there are no attachments. This is case insensitive.
+ */
{ "attach_sep", DT_STR, R_NONE, UL &AttachSep, UL "\n" },
/*
** .pp
diff -ur mutt-1.5.3.orig/mutt.h mutt-1.5.3/mutt.h
--- mutt-1.5.3.orig/mutt.h 2002-12-07 00:37:21.000000000 +0800
+++ mutt-1.5.3/mutt.h 2003-02-23 02:53:21.000000000 +0800
@@ -295,7 +295,8 @@
OPT_SUBJECT,
OPT_MIMEFWDREST,
OPT_FORWEDIT,
- OPT_MAX
+ OPT_MAX,
+ OPT_ATTACH
};
/* flags to ci_send_message() */
diff -ur mutt-1.5.3.orig/send.c mutt-1.5.3/send.c
--- mutt-1.5.3.orig/send.c 2002-12-12 06:45:38.000000000 +0800
+++ mutt-1.5.3/send.c 2003-02-23 02:55:41.000000000 +0800
@@ -1027,6 +1027,34 @@
}
int
+mutt_search_attach_keyword(char* filename)
+{
+ /* searches for the magic keyword "attach" within a file */
+ int found = 0;
+ char* inputline = malloc(1024);
+ char* lowerKeyword = malloc(strlen(AttachKeyword)+1);
+ FILE *attf = fopen(filename, "r");
+ int i;
+ for (i=0; i <= strlen(AttachKeyword); i++) {
+ lowerKeyword[i] = tolower(AttachKeyword[i]);
+ }
+ while (!feof(attf)) {
+ fgets(inputline, 1024, attf);
+ for (i=0; i < strlen(inputline); i++) {
+ inputline[i] = tolower(inputline[i]);
+ }
+ if (strstr(inputline, lowerKeyword)) {
+ found = 1;
+ break;
+ }
+ }
+ free(inputline);
+ free(lowerKeyword);
+ fclose(attf);
+ return found;
+}
+
+int
ci_send_message (int flags, /* send mode */
HEADER *msg, /* template to use for new message */
char *tempfile, /* file specified by -i or -H */
@@ -1452,6 +1480,21 @@
goto main_loop;
}
+ if (mutt_search_attach_keyword(msg->content->filename) &&
+ !msg->content->next &&
+ query_quadoption(OPT_ATTACH, _("No attachments, cancel sending?")) !=
M_NO)
+ {
+ /* if the abort is automatic, print an error message */
+ if (quadoption (OPT_ATTACH) == M_YES) {
+ char errorstr[512];
+ if (snprintf(errorstr, 512,
+ "Message contains magic keyword \"%s\", but no
attachments. Not sending.", AttachKeyword)==-1)
+ errorstr[511] = 0; // terminate if need be. our string shouldnt
be this long.
+ mutt_error _(errorstr);
+ }
+ goto main_loop;
+ }
+
if (msg->content->next)
msg->content = mutt_make_multipart (msg->content);
pgpnKjz08nhhf.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ---
The bug is tagged as wontfix and the upstream suggested a wiki link
as a workaround, we can resolve this on this side
Cheers
Antonio
--- End Message ---