From: Ken Hornstein Date: Fri, 10 Jan 2014 04:17:25 +0000 (-0500) Subject: A bit closer, but don't run the test just yet. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/e4f6d48f7af4db62523d5351e2cf2849caa6ce54?ds=sidebyside;hp=430ffdd38f6ea76f20d8559a3e2a6f7835117d47 A bit closer, but don't run the test just yet. --- diff --git a/test/mhbuild/test-attach b/test/mhbuild/test-attach new file mode 100755 index 00000000..8bd3a64e --- /dev/null +++ b/test/mhbuild/test-attach @@ -0,0 +1,38 @@ +#!/bin/sh +###################################################### +# +# Test the use of the Attach: header +# +###################################################### + +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname "$0"`/../.. + MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR +fi + +. "$MH_OBJ_DIR/test/common.sh" + +setup_test + +draft="$MH_TEST_DIR/$$.draft" +expected="$MH_TEST_DIR/$$.expected" +actual="$MH_TEST_DIR/$$.actual" + +# +# Test out a simple draft +# + +cat > "$draft" < +cc: +Fcc: +outbox +Attach: ${srcdir}/test/mhbuild/tiny.jpg +------ +Test +EOF + +mhbuild "$draft" + +cat $draft + +exit $failed diff --git a/test/mhbuild/tiny.jpg b/test/mhbuild/tiny.jpg new file mode 100644 index 00000000..d17e4da5 --- /dev/null +++ b/test/mhbuild/tiny.jpg @@ -0,0 +1 @@ +ÿØ \ No newline at end of file diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 58540f1b..efd3c64f 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -211,10 +211,30 @@ build_mime (char *infile, int directives, int header_encoding) if (strcasecmp(ATTACH_FIELD, np) == 0) { struct attach_list *entry; + char *s = vp, *e = vp + strlen(vp) - 1; free(np); + + /* + * Make sure we can find the start of this filename. + * If it's blank, we skip completely. Otherwise, strip + * off any leading spaces and trailing newlines. + */ + + while (isspace((unsigned char) *s)) + s++; + + while (e > s && *e == '\n') + *e-- = '\0'; + + if (*s == '\0') { + free(vp); + goto finish_field; + } + entry = mh_xmalloc(sizeof(*entry)); - entry->filename = vp; - if (! attach_tail) { + entry->filename = getcpy(s); + free(vp); + if (attach_tail) { attach_tail->next = entry; attach_tail = entry; } else { @@ -320,7 +340,7 @@ finish_field: struct part *part; CT p; - if (! access(at_entry->filename, R_OK)) { + if (access(at_entry->filename, R_OK) != 0) { adios("reading", "Unable to open %s for", at_entry->filename); } @@ -1853,6 +1873,7 @@ setup_attach_content(CT ct, const char *filename) } ct->c_descr = getcpy(filename); + ct->c_cefile.ce_file = getcpy(filename); /* * If it's a text/calendar, we need to make sure it's an inline,