FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=18578&edit=1

ID: 18578
Updated by: alan@akbkhome.com
Reported By: ruediger dot bente at gmx dot de
Summary: Can't get the filename of an attachment
-Status: Feedback
+Status: Closed
Type: Bug
Package: Mail_mimeDecode
Operating System: Linux (Ubuntu-Server)
Package Version: 1.5.5
PHP Version: 5.3.1
-Assigned To:
+Assigned To: alan_k
Roadmap Versions:
New Comment:

-Status: Feedback
+Status: Closed
-Assigned To:
+Assigned To: alan_k
This bug has been fixed in SVN.

If this was a documentation problem, the fix will appear on pear.php.net
by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should
be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.

Found the problem.. should be fixed in svn.


Previous Comments:
------------------------------------------------------------------------

[2011-08-22 07:33:31] alan_k

-Status: Open
+Status: Feedback
We are unable to reproduce the bug as reported.
Please provide a simple script (10 lines or less)
or a link to an external script that can be used
to reproduce the bug.

If you can provide the script, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PEAR.


I tried reproducing this, seed ->ctype_parameters['name'] - it appears
to work ok.

MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_NextPart_000_00D9_01CC5841.3C854FF0"

Subject: test

This is a multi-part message in MIME format.

------=_NextPart_000_00D9_01CC5841.3C854FF0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit

test



------=_NextPart_000_00D9_01CC5841.3C854FF0
Content-Type: application/pdf;
name="=?UTF-8?B?QmVrbGVpZHVuZ3NtYcOfZS5wZGY=?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename*0*=UTF-8''%42%65%6B%6C%65%69%64%75%6E%67%73%6D%61%C3%9F%65%2E%70;
filename*1*=%64%66

JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0ZpbHRlci9GbGF0
ZURlY29kZT4+CnN0cmVhbQp4nM2dS6/uNnam5/4VexzAO5JIiRJgHKBcrmqgZ5UYyCDILJ0G
.......

------=_NextPart_000_00D9_01CC5841.3C854FF0--

<?php

require_once 'Mail/mimeDecode.php';


$structure = Mail_mimeDecode::decode(array(
'include_bodies' => true,
'decode_bodies' => true,
'decode_headers' => true,
'input' => file_get_contents(__DIR__.'/bug18578.txt'),
));


print_r($structure);




stdClass Object
(
[headers] => Array
(
[mime-version] => 1.0
[content-type] => multipart/mixed;
boundary="----=_NextPart_000_00D9_01CC5841.3C854FF0"
)

[ctype_primary] => multipart
[ctype_secondary] => mixed
[ctype_parameters] => Array
(
[boundary] => ----=_NextPart_000_00D9_01CC5841.3C854FF0
)

[parts] => Array
(
[0] => stdClass Object
(
[headers] => Array
(
[content-type] => text/plain;
charset="us-ascii"
[content-transfer-encoding] => 7bit
)

[ctype_primary] => text
[ctype_secondary] => plain
[ctype_parameters] => Array
(
[charset] => us-ascii
)

[body] => test




)

[1] => stdClass Object
(
[headers] => Array
(
[content-type] => application/pdf;
name="Bekleidungsmaße.pdf"
[content-transfer-encoding] => base64
[content-disposition] => attachment;
filename*0*=UTF-8''%42%65%6B%6C%65%69%64%75%6E%67%73%6D%61%C3%9F%65%2E%70;
filename*1*=%64%66
)

[ctype_primary] => application
[ctype_secondary] => pdf
[ctype_parameters] => Array
(
[name] => Bekleidungsmaße.pdf
)

[disposition] => attachment
[d_parameters] => Array
(
[filename*0*] =>
UTF-8%42%65%6B%6C%65%69%64%75%6E%67%73%6D%61%C3%9F%65%2E%70
[filename*1*] => %64%66
)

[body] => %PDF-1.4
%äüöß
2 0 obj
<</Length 3 0 R/Filter/FlateDecode>>
stream
x??K??6v???{?;?H?`?\?j?g?? ?,?
)

)

)

------------------------------------------------------------------------

[2011-06-01 14:26:08] ruebezahl

Description:
------------
$part->ctype_parameters['filename'] has no valid value or is blank.

Mimepart of the attachement looks like this:

--------------060808080706060305030508
Content-Type: application/pdf;
name="=?UTF-8?B?QmVrbGVpZHVuZ3NtYcOfZS5wZGY=?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename*0*=UTF-8''%42%65%6B%6C%65%69%64%75%6E%67%73%6D%61%C3%9F%65%2E%70;
filename*1*=%64%66

JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0ZpbHRlci9GbGF0
ZURlY29kZT4+CnN0cmVhbQp4nM2dS6/uNnam5/4VexzAO5JIiRJgHKBcrmqgZ5UYyCDILJ0G
.......

Mail was sent by Thunderbird 3.1.10

Test script:
---------------
require_once 'Mail/mimeDecode.php';

$input = file_get_contents("/tmp/druckmessage");
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$params['input'] = $input;
$structure = Mail_mimeDecode::decode($params);

foreach ($structure->parts as $part)
{
// only save if an attachment
if (isset($part->disposition) and
($part->disposition=='attachment'))
{
// open file
$fp = fopen($part->ctype_parameters['filename'], 'w');
// write body
fwrite($fp, $part->body);
// close file
fclose($fp);
}
}

Expected result:
----------------
Like to get the filename out of the mimepart header

Actual result:
--------------
filename is blank

after adding a
print_r($structure->ctype_parameters);
before the foreach
and a
print($part->ctype_primary . ' // ' . $part->disposition);
after the foreach
the result is the following:

Array
(
[boundary] => ------------060808080706060305030508
)
text //
application // attachment

------------------------------------------------------------------------

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
grouppear-bugs @
categoriesphp
postedAug 22, '11 at 5:33a
activeAug 22, '11 at 7:38a
posts2
users1
websitepear.php.net

1 user in discussion

Alan: 2 posts

People

Translate

site design / logo © 2022 Grokbase