[imp] Forward will not copy original info

Gary Windham windhamg at email.arizona.edu
Fri May 21 10:53:12 PDT 2004


Quoting EB <horde at rnet-tech.com>:

> I am using CVS HEAD.
>
> When I attempt to forward a particular mail, the compose window comes
> up empty
> and none of the information from the original appears.
>
> However, this only happens on email from one source when there is a PDF
> attached.  I am able to forward mail from other sources with PDFs, and other
> email from this source when there is no PDF attached.
>
> Any idea what I can do to fix or further diagnose this?

<long-winded reply>

I ran into this same problem with CVS HEAD.  I tracked it down, and figured out
the cause (I think).

In my case, this happens when the PDF document MIME part has a Content-type of
"application/octet-stream".  When forwarding the message, the call to
IMP_Compose::addMIMEPartAttachment() will save the body part in a temporary
file, called "impatt<random string>", thereby losing the ".pdf" extension.

The subsequent call to MIME_Magic::analyzeFile() doesn't succeed, as there is no
PDF signature in the framework/MIME/MIME/mime.magic.php file.  The following
all to MIME_Magic::filenameToMIME() (which calls MIME_Magic::extToMIME()) can't
map the extension (.pdf), as it was lost when the body part was saved as
"impatt<random string>".

Still with me?  Good. ;)

MIME_Magic::extToMIME() behavior is such that, if passed an empty extension, it
returns a MIME type of "text/plain".  This then forces the later call to
MIME_Part::getBytes() to treat the contents as text, and the String::length()
function is run against the (non-text) data, which is where PHP is dying.

I fixed this by changing the behavior of MIME_Magic::extToMIME() as shown in the
attached patch.  I think the intent in the extMIME() function was that if
somebody attaches a text file called "foo" (no extension), which can't be
mapped by the magic file (since it's plain text), it makes sense to treat it as
"text/plain".  However, these "application/octet-stream" attachments which
can't be mapped (I also had an MS Word document the other day that didn't match
any of the signatures in mime.magic.php--it had the same issue when forwarding)
make this approach less practical.

</long-winded reply>

--
Gary Windham
Systems Programmer, Principal
The University of Arizona, CCIT
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Magic_php.diff
Type: text/x-patch
Size: 401 bytes
Desc: not available
Url : http://lists.horde.org/archives/imp/attachments/20040521/0aa9b7f2/Magic_php.bin


More information about the imp mailing list