From 18aa168e2c8ac7534c6b4233675b8ec711edb5c4 Mon Sep 17 00:00:00 2001 From: philippe_mingo Date: Wed, 6 Feb 2002 10:14:07 +0000 Subject: [PATCH] There was a problem when passing arrays to the decode header. From now, if an array is passed we run a conversion on that array to transform it to a \n separated string. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2371 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/mime.php | 47 ++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/functions/mime.php b/functions/mime.php index 7ff84235..e9a6b4a9 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -770,33 +770,40 @@ function decodeBody($body, $encoding) { * RFC1522 (MIME Part Two: Message Header Extensions for Non-ASCII Text). */ function decodeHeader ($string, $utfencode=true) { - if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=', + +if ( is_array( $string ) ) { + $string = implode("\n", $string ); +} + +if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=', $string, $res)) { - if (ucfirst($res[2]) == 'B') { + if (ucfirst($res[2]) == 'B') { $replace = base64_decode($res[3]); - } else { + } else { $replace = str_replace('_', ' ', $res[3]); - // Convert lowercase Quoted Printable to uppercase for - // quoted_printable_decode to understand it. - while (ereg("(=(([0-9][abcdef])|([abcdef][0-9])|([abcdef][abcdef])))", $replace, $res)) { - $replace = str_replace($res[1], strtoupper($res[1]), $replace); - } + // Convert lowercase Quoted Printable to uppercase for + // quoted_printable_decode to understand it. + while (ereg("(=(([0-9][abcdef])|([abcdef][0-9])|([abcdef][abcdef])))", + $replace, $res)) { + $replace = str_replace($res[1], strtoupper($res[1]), $replace); + } $replace = quoted_printable_decode($replace); - } - /* Only encode into entities by default. Some places + } + /* Only encode into entities by default. Some places don't need the encoding, like the compose form. */ - if ($utfencode){ - $replace = charset_decode ($res[1], $replace); - } + if ($utfencode){ + $replace = charset_decode ($res[1], $replace); + } + + // Remove the name of the character set. + $string = eregi_replace ('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=', + $replace, $string); - // Remove the name of the character set. - $string = eregi_replace ('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=', - $replace, $string); + // In case there should be more encoding in the string: recurse + $string = decodeHeader($string); +} - // In case there should be more encoding in the string: recurse - return (decodeHeader($string)); - } else - return ($string); +return ($string); } /* -- 2.25.1