From: Philip Hazel Date: Wed, 31 Jan 2007 11:30:08 +0000 (+0000) Subject: Add ${rfc2047d: expansion. X-Git-Tag: exim-4_67~53 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9c57cbc06f4506e05f63190afddfc9b3648813cb;p=exim.git Add ${rfc2047d: expansion. --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index f487761c7..e36d4bb50 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.465 2007/01/30 15:10:58 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.466 2007/01/31 11:30:08 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -67,6 +67,8 @@ PH/12 Added $sending_ip_address and $sending_port (mostly Magnus Holmgren's the connection is made in the smtp transport (so it can use these values). +PH/13 Added ${rfc2047d: to decoded RFC 2047 strings. + Exim version 4.66 ----------------- diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff index bdfe78c22..cfa846c48 100644 --- a/doc/doc-txt/NewStuff +++ b/doc/doc-txt/NewStuff @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/NewStuff,v 1.132 2007/01/30 15:10:58 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/NewStuff,v 1.133 2007/01/31 11:30:08 ph10 Exp $ New Features in Exim -------------------- @@ -222,6 +222,12 @@ Version 4.67 The use of helo_data applies both to sending messages and when doing callouts. + 9. There is a new expansion operator ${rfc2047d: that decodes strings that + are encoded as per RFC 2047. Binary zero bytes are replaced by question + marks. Characters are converted into the character set defined by + headers_charset. Overlong RFC 2047 "words" are not recognized unless + check_rfc2047_length is set false. + Version 4.66 ------------ diff --git a/src/ACKNOWLEDGMENTS b/src/ACKNOWLEDGMENTS index 23a6de7ff..a855be12c 100644 --- a/src/ACKNOWLEDGMENTS +++ b/src/ACKNOWLEDGMENTS @@ -1,4 +1,4 @@ -$Cambridge: exim/src/ACKNOWLEDGMENTS,v 1.69 2007/01/30 15:10:59 ph10 Exp $ +$Cambridge: exim/src/ACKNOWLEDGMENTS,v 1.70 2007/01/31 11:30:08 ph10 Exp $ EXIM ACKNOWLEDGEMENTS @@ -20,7 +20,7 @@ relatively small patches. Philip Hazel Lists created: 20 November 2002 -Last updated: 30 January 2007 +Last updated: 31 January 2007 THE OLD LIST @@ -167,7 +167,8 @@ Jakob Hirsch Patch for % operator Magnus Holmgren Patch for filter_prepend_home Patch for "h" flag in Domain Keys Patch for $sending_ip_address/$sending_port - Lots of other support + Patch for ${rfc2047d: + Lots of other maintenance support Kjetil Torgrim Homme Patch for require_files problem on NFS file systems Tom Hughes Suggested patch for $n bug in pipe command from filter Pierre Humblet Continued Cygwin support diff --git a/src/src/expand.c b/src/src/expand.c index a9b474939..b2674dd42 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/expand.c,v 1.78 2007/01/30 15:10:59 ph10 Exp $ */ +/* $Cambridge: exim/src/src/expand.c,v 1.79 2007/01/31 11:30:08 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -181,6 +181,7 @@ static uschar *op_table_main[] = { US"nhash", US"quote", US"rfc2047", + US"rfc2047d", US"rxquote", US"s", US"sha1", @@ -211,6 +212,7 @@ enum { EOP_NHASH, EOP_QUOTE, EOP_RFC2047, + EOP_RFC2047D, EOP_RXQUOTE, EOP_S, EOP_SHA1, @@ -5084,6 +5086,23 @@ while (*s != 0) continue; } + /* RFC 2047 decode */ + + case EOP_RFC2047D: + { + int len; + uschar *error; + uschar *decoded = rfc2047_decode(sub, check_rfc2047_length, + headers_charset, '?', &len, &error); + if (error != NULL) + { + expand_string_message = error; + goto EXPAND_FAILED; + } + yield = string_cat(yield, &size, &ptr, decoded, len); + continue; + } + /* from_utf8 converts UTF-8 to 8859-1, turning non-existent chars into underscores */ diff --git a/test/scripts/0000-Basic/0002 b/test/scripts/0000-Basic/0002 index c31b9232f..f32b605b0 100644 --- a/test/scripts/0000-Basic/0002 +++ b/test/scripts/0000-Basic/0002 @@ -502,6 +502,13 @@ abcd ${rfc2047:abcd} Long: ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit} Long: ${rfc2047: here we go: a string that is going to be encoded: it will go over the 75-char limit by a long way; in fact this one will go over the 150 character limit} +# RFC 2047 decode + +${rfc2047d:abcd abcd} +${rfc2047d:<:abcd:> =?iso-8859-8?Q?=3C=3Aabcd=3A=3E?=} +${rfc2047d:<:ab cd:> =?iso-8859-8?Q?=3C=3Aab_cd=3A=3E?=} +${rfc2047d:Long: =?iso-8859-8?Q?_here_we_go=3A_a_string_that_is_going_to_be_encoded=3A_i?= =?iso-8859-8?Q?t_will_go_over_the_75-char_limit?=} +${rfc2047d:Long: =?iso-8859-8?Q?_here_we_go=3A_a_string_that_is_going_to_be_encoded=3A_i?= =?iso-8859-8?Q?t_will_go_over_the_75-char_limit_by_a_long_way=3B_in_fac?= =?iso-8859-8?Q?t_this_one_will_go_over_the_150_character_limit?=} # UTF-8 diff --git a/test/stdout/0002 b/test/stdout/0002 index a4e6feb2f..623e5769b 100644 --- a/test/stdout/0002 +++ b/test/stdout/0002 @@ -471,6 +471,13 @@ > Long: =?iso-8859-8?Q?_here_we_go=3A_a_string_that_is_going_to_be_encoded=3A_i?= =?iso-8859-8?Q?t_will_go_over_the_75-char_limit?= > Long: =?iso-8859-8?Q?_here_we_go=3A_a_string_that_is_going_to_be_encoded=3A_i?= =?iso-8859-8?Q?t_will_go_over_the_75-char_limit_by_a_long_way=3B_in_fac?= =?iso-8859-8?Q?t_this_one_will_go_over_the_150_character_limit?= > +> # RFC 2047 decode +> +> abcd abcd +> <:abcd:> <:abcd:> +> <:ab cd:> <:ab cd:> +> Long: here we go: a string that is going to be encoded: it will go over the 75-char limit +> Long: here we go: a string that is going to be encoded: it will go over the 75-char limit by a long way; in fact this one will go over the 150 character limit > > # UTF-8 >