Bug #51250 [NEW]: iconv_mime_decode() does not ignore malformed Q-encoded words

From: Date: Tue, 09 Mar 2010 19:49:43 +0000
Subject: Bug #51250 [NEW]: iconv_mime_decode() does not ignore malformed Q-encoded words
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-148446@lists.php.net to get a copy of this message
From:             
Operating system: Linux / Windows
PHP version:      5.2.13
Package:          ICONV related
Bug Type:         Bug
Bug description:iconv_mime_decode() does not ignore malformed Q-encoded words

Description:
------------
When calling iconv_mime_decode() with $mode =
ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 
the manual states that "iconv_mime_decode_headers() attempts to ignore any

grammatical errors and continue to process a given header."

Accordingly, B-encoded encoded-words (as per RFC 2047) are silently
ignored.

But when using Q (quoted-printable) encoding, encoded-words with illegal 
characters (> 127) cause iconv_mime_decode() to return false as if 
ICONV_MIME_DECODE_CONTINUE_ON_ERROR was not specified. 

As such it is not resilient towards malformed headers. 

Test script:
---------------
$m = ICONV_MIME_DECODE_CONTINUE_ON_ERROR;

var_dump(iconv_mime_decode("Legal encoded-word: =?utf-8?B?Kg==?= .", $m));
var_dump(iconv_mime_decode("Legal encoded-word: =?utf-8?Q?*?= .", $m));
var_dump(iconv_mime_decode("Illegal encoded-word: =?utf-8?B?".chr(0xA1)."?=
.", $m));
var_dump(iconv_mime_decode("Illegal encoded-word: =?utf-8?Q?".chr(0xA1)."?=
.", $m));

Expected result:
----------------
string(23) "Legal encoded-word: * ."
string(23) "Legal encoded-word: * ."
string(24) "Illegal encoded-word:  ."
string(24) "Illegal encoded-word:  ."

Actual result:
--------------
string(23) "Legal encoded-word: * ."
string(23) "Legal encoded-word: * ."
string(24) "Illegal encoded-word:  ."
bool(false)

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51250&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51250&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51250&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51250&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51250&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51250&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51250&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51250&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51250&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51250&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51250&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51250&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51250&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51250&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51250&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51250&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51250&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51250&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51250&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51250&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51250&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51250&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#148446) next »