|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29851 Quotes in header From: corrupts imap_headerinfo
Submitted: 2004-08-26 16:51 UTC Modified: 2004-08-27 03:03 UTC
From: janders at javeo dot com Assigned:
Status: Not a bug Package: IMAP related
PHP Version: 4.3.8 OS: RHEL V3
Private report: No CVE-ID: None
 [2004-08-26 16:51 UTC] janders at javeo dot com
Email message header with additional quotes in From: field corrupts results returned by imap_headerinfo.

Message with this from field:
From: "30"TV" <>" 

imap_headerinfo produces:
stdClass Object
    [date] => Wed, 25 Aug 2004 19:16:52 -0800
    [Date] => Wed, 25 Aug 2004 19:16:52 -0800
    [subject] => Free to new members- Flat Screen TV 
    [Subject] => Free to new members- Flat Screen TV 
    [fromaddress] => "30TV <>"@t1
    [from] => Array([0] => stdClass Object
                 [mailbox] => 30TV <>
                 [host] => t1

Reading this message from imap server using Outlook produces correct results, with additional quotes simply removed.  I also read this message from imap server using Pine, since php uses same c-client.  When displaying the message header in Pine, Pine replaced the corrupt "From" field with the non-corrupt "To" field when message header is displayed in the Inbox.



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-27 00:47 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

The header seems to corrupt in the 1st place. 
 [2004-08-27 03:03 UTC] janders at javeo dot com
I disagree...  Php is returning invalid data. Just because the From: field is invalid syntax, that doesn't mean that php should follow suit and provide invalid data.  

On call to imap_headerinfo, it's returning an invalid mailbox -- i.e., "30TV <>"@t1. The code should return an error message or error code, or should return "carpenter", which is the mailbox, and it should properly set "" as the host object.

Obviously php is mangling the original field in an attempt to return a valid mailbox string.  So, if before returning the string, if php did a simple regexp to test for invalid chars like,

if (!ereg("/^([a-zA-Z0-9_\.\-])+/", $str)

then it could determin if the mailbox string was valid or not before returning yet another invalid string.

Oh well, if not fixed in php I guess I'll have to run my 'if' condition against every mailbox returned by imap_headerinfo.

Thanks again for your help,
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Sep 23 05:01:23 2023 UTC