Bug #66117 [Opn->Fbk]: imap_fetchstructure dparameters[0]->value incomplete
Edit report at https://bugs.php.net/bug.php?id=66117&edit=1
ID: 66117
Updated by: cmb@php.net
Reported by: saygushkin at gmail dot com
Summary: imap_fetchstructure dparameters[0]->value incomplete
-Status: Open
+Status: Feedback
Type: Bug
Package: IMAP related
Operating System: Linux
PHP Version: 5.4.22
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Based on requinix' comment, it's pretty clear what happens: the
continuation is ignored. I can, however, not reproduce the
reported behavior.
Previous Comments:
------------------------------------------------------------------------
[2013-11-19 19:21:51] requinix@php.net
Expected and actual outputs are backwards.
The relevant RFC is #2231: "MIME Parameter Value and Encoded Word Extensions: Character Sets,
Languages, and Continuations"
http://tools.ietf.org/html/rfc2231
tl;dr: the filename would be interpreted as coming in multiple parts (because of the *Ns) and
contains charset info (because of the trailing *s), and the value is decoded as UTF-8 (raw value is
formatted as charset'language'value).
------------------------------------------------------------------------
[2013-11-19 13:05:54] saygushkin at gmail dot com
fix summary
------------------------------------------------------------------------
[2013-11-19 13:01:14] saygushkin at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.imap-fetchstructure#refsect1-function.imap-fetchstructure-returnvalues
---
I attached to the mail of the file with name "пÑÑÑой
Ñайл.txt".
Filename in dparameters->value is incomplete.
Mail source code:
--------------030200090909050404050001
Content-Type: text/plain; charset="UTF-8";
name="=?UTF-8?B?0L/Rg9GB0YLQvtC5INGE0LDQudC7LnR4dA==?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename*0*="UTF-8''%D0%BF%D1%83%D1%81%D1%82%D0%BE%D0%B9%20%D1%84%D0%B0%D0";
filename*1*="%B9%D0%BB%2E%74%78%74"
0L/Rg9GB0YLQvtC5INGE0LDQudC7Cg==
--------------030200090909050404050001--
Test script:
---------------
$imapStream = imap_open($imapPath, $login, $password);
$mailIds = imap_search($imapStream, 'ALL', SE_UID);
$mailId = array_shift(mailIds);
$mailStructure = imap_fetchstructure($imapStream, $mailId, FT_UID);
var_dump($mailStructure);
var_dump($mailStructure->parts[1]->dparameters[0]->value);
var_dump(urldecode('%D0%BF%D1%83%D1%81%D1%82%D0%BE%D0%B9%20%D1%84%D0%B0%D0'));
Expected result:
----------------
["dparameters"]=>
array(1) {
[0]=>
object(stdClass)#724 (2) {
["attribute"]=>
string(8) "filename"
["value"]=>
string(61) "UTF-8''%D0%BF%D1%83%D1%81%D1%82%D0%BE%D0%B9%20%D1%84%D0%B0%D0"
}
}
["ifparameters"]=>
int(1)
["parameters"]=>
array(2) {
[0]=>
object(stdClass)#725 (2) {
["attribute"]=>
string(7) "charset"
["value"]=>
string(5) "UTF-8"
}
[1]=>
object(stdClass)#726 (2) {
["attribute"]=>
string(4) "name"
["value"]=>
string(48) "=?UTF-8?B?0L/Rg9GB0YLQvtC5INGE0LDQudC7LnR4dA==?="
}
}
string(61) "UTF-8''%D0%BF%D1%83%D1%81%D1%82%D0%BE%D0%B9%20%D1%84%D0%B0%D0"
string(18) "пÑÑÑой Ñа�"
Actual result:
--------------
["dparameters"]=>
array(1) {
[0]=>
object(stdClass)#724 (2) {
["attribute"]=>
string(8) "filename"
["value"]=>
string(61)
"UTF-8''%D0%BF%D1%83%D1%81%D1%82%D0%BE%D0%B9%20%D1%84%D0%B0%D0%B9%D0%BB%2E%74%78%74"
}
}
["ifparameters"]=>
int(1)
["parameters"]=>
array(2) {
[0]=>
object(stdClass)#725 (2) {
["attribute"]=>
string(7) "charset"
["value"]=>
string(5) "UTF-8"
}
[1]=>
object(stdClass)#726 (2) {
["attribute"]=>
string(4) "name"
["value"]=>
string(48) "=?UTF-8?B?0L/Rg9GB0YLQvtC5INGE0LDQudC7LnR4dA==?="
}
}
string(61)
"UTF-8''%D0%BF%D1%83%D1%81%D1%82%D0%BE%D0%B9%20%D1%84%D0%B0%D0%B9%D0%BB%2E%74%78%74"
string(25) "пÑÑÑой Ñайл.txt"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66117&edit=1
Thread (10 messages)