php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56914 mailparse_msg_get_part_data() gets wrong filename
Submitted: 2006-03-25 10:49 UTC Modified: 2008-03-23 21:58 UTC
From: pecl dot wayne at ptaff dot ca Assigned:
Status: No Feedback Package: mailparse (PECL)
PHP Version: 4.4.0 OS: GNU/Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-03-25 10:49 UTC] pecl dot wayne at ptaff dot ca
Description:
------------
Using mailparse_msg_get_part_data() on a specific mail message truncates the attachment filename.

The relevant mail headers are:

Message-ID: <Pine.LNX.4.63.0511211500190.29068@octet.ca>
MIME-Version: 1.0
Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-184856383-1132603777=:29068"

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--8323328-184856383-1132603777=:29068
Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

[some text]

--8323328-184856383-1132603777=:29068
Content-Type: IMAGE/png; name=I_nw_r1_YUL_2005112112_017.png
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.63.0511211509370.29068@octet.ca>
Content-Description:
Content-Disposition: attachment; filename=I_nw_r1_YUL_2005112112_017.png

[some data]

--8323328-184856383-1132603777=:29068--

You may get the original mail message for testing purposes at:
http://ptaff.ca/arc/mail.txt


Reproduce code:
---------------
This simple test fetches metadata about the message part:

<?php
  $foo = mailparse_msg_parse_file(mailfile.txt);
  $bar = mailparse_msg_get_structure($foo);
  $fred = mailparse_msg_get_part_data($foo);
  $barney = mailparse_msg_get_part($foo, $bar[2]);
  $wilma = mailparse_msg_get_part_data($barney);
  print_r($wilma);
?>


Expected result:
----------------
The [disposition-filename] and [content-name] should have a ".png" extension

Actual result:
--------------
Array
(
    [headers] => Array
        (
            [content-type] => IMAGE/png; name=I_nw_r1_YUL_2005112112_017.png
            [content-transfer-encoding] => BASE64
            [content-id] => <Pine.LNX.4.63.0511211509370.29068@octet.ca>
            [content-description] => 
            [content-disposition] => attachment; filename=I_nw_r1_YUL_2005112112_017.png
        )

    [starting-pos] => 2380
    [starting-pos-body] => 2628
    [ending-pos] => 37386
    [ending-pos-body] => 37386
    [line-count] => 576
    [body-line-count] => 570
    [charset] => us-ascii
    [transfer-encoding] => base64
    [content-name] => I_nw_r1_YUL_2005112112_017
    [content-type] => image/png
    [disposition-filename] => I_nw_r1_YUL_2005112112_017
    [content-disposition] => attachment
    [content-base] => /
    [content-id] => Pine.LNX.4.63.0511211509370.29068@octet.ca
    [content-description] => 
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-03 17:56 UTC] busby at edoceo dot com
RFC822 said the '.' character if included needed to be quoted like this:

Content-Type: application/octet-stream; name="file.pdf"

But RFC 2045 says that "." no longer needs to be quoted.
See Here:
  http://tools.ietf.org/html/2045#page-11

Currently I workaround like this:
$part->name = isset($data['content-name']) ? $data['content-name'] : null;
if preg_match("/name=\"?(.+)\"?;/",$data['headers']['content-type'],$m)) $part->name = $m[1];

Seems to work OK
 [2007-11-25 23:45 UTC] shire@php.net
I'm unable to reproduce this with the latest CVS.  Can you please confirm if the latest release fixes this bug? -thx
 [2008-03-23 21:58 UTC] shire@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 11:01:27 2024 UTC