diff options
| author | Sam Varshavchik | 2018-07-29 10:30:12 -0400 |
|---|---|---|
| committer | Sam Varshavchik | 2018-07-29 10:30:12 -0400 |
| commit | 6c2fe8b0d5be19cdd579bb5b86cec95cab62c320 (patch) | |
| tree | 1c680ff8979be4dcdd288e810cfab25864fc4aa7 | |
| parent | 8110e928827657babbe047832460d768310d789d (diff) | |
| download | courier-libs-6c2fe8b0d5be19cdd579bb5b86cec95cab62c320.tar.bz2 | |
mailbot: support UTF-8 messages.
| -rw-r--r-- | maildrop/mailbot.sgml | 16 | ||||
| -rw-r--r-- | rfc2045/rfc2045reply.c | 64 |
2 files changed, 65 insertions, 15 deletions
diff --git a/maildrop/mailbot.sgml b/maildrop/mailbot.sgml index fdbfe3c..a2e891b 100644 --- a/maildrop/mailbot.sgml +++ b/maildrop/mailbot.sgml @@ -193,11 +193,12 @@ default character set.</para> <blockquote> <informalexample> <programlisting> -Content-Type: text/plain; format=flowed; delsp=yes; charset="iso-8859-1" +Content-Type: text/plain; format=flowed; delsp=yes; + charset="iso-8859-1" -Mary had a little lamb, -Its fleece was white as snow. -And everywhere Mary went, +Mary had a little lamb,   +Its fleece was white as snow.   +And everywhere Mary went,   The lamb was sure to go.</programlisting> </informalexample> </blockquote> @@ -221,7 +222,7 @@ set and formats the autoreply according to the character set read from the <replaceable>address</replaceable> is an <ulink url="http://tools.ietf.org/html/rfc2822">RFC 2822</ulink> E-mail address that generates the DSN. - Note that the <option>-A</option> option should still be used in + Note that the <option>-A</option> option should still be used in addition to <option>-M</option> in order to set the <literal>From:</literal> header on the autoresponse. <option>-M</option> sets the DSN address only. @@ -553,6 +554,11 @@ Set the <literal>Subject:</literal> header on the autoresponse to <quote>--feedback-reported-domain</quote> may be specified more than once. </para> + + <para> + Where appropriate, UTF-8 encoding should be used for non-ASCII + characters. + </para> </listitem> </varlistentry> <varlistentry> diff --git a/rfc2045/rfc2045reply.c b/rfc2045/rfc2045reply.c index cc2cbd8..b9b721f 100644 --- a/rfc2045/rfc2045reply.c +++ b/rfc2045/rfc2045reply.c @@ -1,5 +1,5 @@ /* -** Copyright 2000-2011 Double Precision, Inc. See COPYING for +** Copyright 2000-2018 Double Precision, Inc. See COPYING for ** distribution information. */ @@ -775,7 +775,13 @@ static int mkforward(struct rfc2045_mkreplyinfo *ri) writes(ri, "\n--"); writes(ri, boundary); - writes(ri, "\nContent-Type: message/rfc822\n"); + writes(ri, "\nContent-Type: "); + + writes(ri, first_attachment->rfcviolation & + RFC2045_ERR8BITHEADER + ? RFC2045_MIME_MESSAGE_GLOBAL + : RFC2045_MIME_MESSAGE_RFC822); + writes(ri, "\n"); if (ri->forwarddescr) { @@ -929,7 +935,7 @@ static int mkreply(struct rfc2045_mkreplyinfo *ri) off_t start_pos, end_pos, start_body, dummy; int errflag=0; char *boundary; - char *dsn_report_type; + const char *dsn_report_type; int (*dsn_report_gen)(struct rfc2045_mkreplyinfo *); struct rfc2045headerinfo *hi; @@ -1460,11 +1466,7 @@ static int mkreply(struct rfc2045_mkreplyinfo *ri) writes(ri, "\n--"); writes(ri, boundary); - writes(ri, "\nContent-Type: message/"); - - writes(ri, dsn_report_type); - writes(ri, "\n" - "Content-Transfer-Encoding: 7bit\n\n"); + writes(ri, "\n"); if (errflag == 0) errflag=(*dsn_report_gen)(ri); @@ -1477,7 +1479,14 @@ static int mkreply(struct rfc2045_mkreplyinfo *ri) off_t cnt=end_pos - start_pos; char buf[BUFSIZ]; - writes(ri, "\nContent-Type: message/rfc822\n" + writes(ri, "\nContent-Type: "); + + writes(ri, ri->rfc2045partp->rfcviolation & + RFC2045_ERR8BITHEADER + ? RFC2045_MIME_MESSAGE_GLOBAL + : RFC2045_MIME_MESSAGE_RFC822); + + writes(ri, "\n" "Content-Disposition: attachment\n\n"); if (errflag == 0) @@ -1528,7 +1537,14 @@ static void copyheaders(struct rfc2045_mkreplyinfo *ri) char *header, *value; - writes(ri, "\nContent-Type: text/rfc822-headers; charset=\"utf-8\"\n" + writes(ri, "\nContent-Type: "); + + if (ri->rfc2045partp->rfcviolation & RFC2045_ERR8BITHEADER) + writes(ri, RFC2045_MIME_MESSAGE_GLOBAL_HEADERS); + else + writes(ri, RFC2045_MIME_MESSAGE_HEADERS); + + writes(ri, "; charset=\"utf-8\"\n" "Content-Disposition: attachment\n" "Content-Transfer-Encoding: 8bit\n\n" ); @@ -1580,6 +1596,31 @@ static int replydraft(struct rfc2045_mkreplyinfo *ri) static int replydsn(struct rfc2045_mkreplyinfo *ri) { + const char *p; + int is8bit=0; + + for (p=ri->dsnfrom; *p; ++p) + if (*p & 0x80) + { + is8bit=1; + break; + } + + if (is8bit) + { + writes(ri, "Content-Type: " + RFC2045_MIME_MESSAGE_GLOBAL_DELIVERY_STATUS + "; charset=\"utf-8\"\n"); + writes(ri, "Content-Transfer-Encoding: 8bit\n\n"); + } + else + { + writes(ri, "Content-Type: " + RFC2045_MIME_MESSAGE_DELIVERY_STATUS + "\n"); + writes(ri, "Content-Transfer-Encoding: 7bit\n\n"); + } + dsn_arrival_date(ri); writes (ri, "\n" @@ -1597,6 +1638,9 @@ static int replyfeedback(struct rfc2045_mkreplyinfo *ri) { size_t i; + writes(ri, "Content-Type: message/feedback-report; charset=\"utf-8\"\n"); + writes(ri, "Content-Transfer-Encoding: 8bit\n\n"); + dsn_arrival_date(ri); writes(ri, "User-Agent: librfc2045 " RFC2045PKG "/" RFC2045VER |
