Bug #67207 [Opn->Nab]: imap_headerinfo bug for utf8-encoded "from" header field

From: Date: Wed, 14 Oct 2020 12:49:10 +0000
Subject: Bug #67207 [Opn->Nab]: imap_headerinfo bug for utf8-encoded "from" header field
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229614@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67207&edit=1

 ID:                 67207
 Updated by:         cmb@php.net
 Reported by:        e dot lemanissier at physioflow dot com
 Summary:            imap_headerinfo bug for utf8-encoded "from" header
                     field
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            IMAP related
 PHP Version:        5.4.28
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

I can basically reproduce this.  The problem is the already broken
From header:

    =?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?=@UNKNOWN

The @UNKNOW has apparently been added by an MTA; the actual domain
should have been @1and1.fr.  Anyhow, this From header causes the
libc-client function mail_fetchenvelope() to misbehave, while
mail_fetchheader_full() and a following rfc822_parse_msg() yield
the desired results.

So this is not a bug in PHP's IMAP extension, but rather a fail
of libc-client to properly process erroneously composed or transmitted
email addresses.


Previous Comments:
------------------------------------------------------------------------
[2015-08-31 08:57:40] e dot lemanissier at physioflow dot com

from phpinfo:

PHP Version 5.5.28
System	Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux
IMAP c-Client Version	2007e

------------------------------------------------------------------------
[2015-08-29 16:09:17] cmb@php.net

I'm not able to reproduce this issue with "recent" versions of
libc-client (2007e and 2007f). Which version do you use (see PHP
info)? Which OS are you running?

------------------------------------------------------------------------
[2014-05-05 11:20:31] e dot lemanissier at physioflow dot com

Description:
------------
When using the imap_headerinfo on an email with an utf8 encoded from header (for example
=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?), the returned variable does not have
any from field. The from information is however available if
imap_rfc822_parse_headers(imap_fetchheader()) is used.



Test script:
---------------
var_dump(imap_headerinfo($this->mbox, $mid));
var_dump(imap_fetchheader($this->mbox, $mid));
var_dump(imap_rfc822_parse_headers(imap_fetchheader($this->mbox, $mid)));

Expected result:
----------------
object(stdClass)#22 (17) {
  ["date"]=>
  string(31) "Fri, 11 Apr 2014 03:27:57 +0100"
  ["Date"]=>
  string(31) "Fri, 11 Apr 2014 03:27:57 +0100"
  ["subject"]=>
  string(72) "Rapport quotidien du dossier Spam du compte email support@XXX.com"
  ["Subject"]=>
  string(72) "Rapport quotidien du dossier Spam du compte email support@XXX.com"
  ["message_id"]=>
  string(46) "<0MRpI7-1WRWOS48ML-00Skij@spamreport.1and1.fr>"
  ["toaddress"]=>
  string(22) "support@XXX.com"
  ["to"]=>
  array(1) {
    [0]=>
    object(stdClass)#26 (2) {
      ["mailbox"]=>
      string(7) "support"
      ["host"]=>
      string(14) "XXX.com"
    }
  }
  ["fromaddress"]=>
  string(69) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?=@UNKNOWN"
  ["from"]=>
  array(1) {
    [0]=>
    object(stdClass)#29 (2) {
      ["mailbox"]=>
      string(61) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?="
      ["host"]=>
      string(7) "UNKNOWN"
    }
  }
  ["Recent"]=>
  string(1) " "
  ["Unseen"]=>
  string(1) " "
  ["Flagged"]=>
  string(1) " "
  ["Answered"]=>
  string(1) " "
  ["Deleted"]=>
  string(1) " "
  ["Draft"]=>
  string(1) " "
  ["Msgno"]=>
  string(4) "   1"
  ["MailDate"]=>
  string(26) "11-Apr-2014 01:27:57 +0000"
  ["Size"]=>
  string(3) "922"
  ["udate"]=>
  int(1397179677)
}
string(655) "Return-Path: <>
Delivery-Date: Fri, 11 Apr 2014 03:27:57 +0100
Received: from spamreport by localhost id 0MRpI7-1WRWOS48ML-00Skij for
        support@XXX.com (mailbox m51559649-71621086);
        Fri, 11 Apr 2014 03:27:57 +0100
From: =?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?=
Subject: Rapport quotidien du dossier Spam du compte email
        support@XXX.com
Date: Fri, 11 Apr 2014 03:27:57 +0100
To: <support@XXX.com>
Message-Id: <0MRpI7-1WRWOS48ML-00Skij@spamreport.1and1.fr>
Envelope-To: support@XXX.com
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

"
object(stdClass)#27 (13) {
  ["date"]=>
  string(31) "Fri, 11 Apr 2014 03:27:57 +0100"
  ["Date"]=>
  string(31) "Fri, 11 Apr 2014 03:27:57 +0100"
  ["subject"]=>
  string(72) "Rapport quotidien du dossier Spam du compte email support@XXX.com"
  ["Subject"]=>
  string(72) "Rapport quotidien du dossier Spam du compte email support@XXX.com"
  ["message_id"]=>
  string(46) "<0MRpI7-1WRWOS48ML-00Skij@spamreport.1and1.fr>"
  ["toaddress"]=>
  string(22) "support@XXX.com"
  ["to"]=>
  array(1) {
    [0]=>
    object(stdClass)#28 (2) {
      ["mailbox"]=>
      string(7) "support"
      ["host"]=>
      string(14) "XXX.com"
    }
  }
  ["fromaddress"]=>
  string(69) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?=@UNKNOWN"
  ["from"]=>
  array(1) {
    [0]=>
    object(stdClass)#29 (2) {
      ["mailbox"]=>
      string(61) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?="
      ["host"]=>
      string(7) "UNKNOWN"
    }
  }
  ["reply_toaddress"]=>
  string(69) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?=@UNKNOWN"
  ["reply_to"]=>
  array(1) {
    [0]=>
    object(stdClass)#30 (2) {
      ["mailbox"]=>
      string(61) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?="
      ["host"]=>
      string(7) "UNKNOWN"
    }
  }
  ["senderaddress"]=>
  string(69) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?=@UNKNOWN"
  ["sender"]=>
  array(1) {
    [0]=>
    object(stdClass)#31 (2) {
      ["mailbox"]=>
      string(61) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?="
      ["host"]=>
      string(7) "UNKNOWN"
    }
  }
}


Actual result:
--------------
object(stdClass)#22 (17) {
  ["date"]=>
  string(31) "Fri, 11 Apr 2014 03:27:57 +0100"
  ["Date"]=>
  string(31) "Fri, 11 Apr 2014 03:27:57 +0100"
  ["subject"]=>
  string(72) "Rapport quotidien du dossier Spam du compte email support@XXX.com"
  ["Subject"]=>
  string(72) "Rapport quotidien du dossier Spam du compte email support@XXX.com"
  ["message_id"]=>
  string(46) "<0MRpI7-1WRWOS48ML-00Skij@spamreport.1and1.fr>"
  ["toaddress"]=>
  string(22) "support@XXX.com"
  ["to"]=>
  array(1) {
    [0]=>
    object(stdClass)#26 (2) {
      ["mailbox"]=>
      string(7) "support"
      ["host"]=>
      string(14) "XXX.com"
    }
  }
  ["Recent"]=>
  string(1) " "
  ["Unseen"]=>
  string(1) " "
  ["Flagged"]=>
  string(1) " "
  ["Answered"]=>
  string(1) " "
  ["Deleted"]=>
  string(1) " "
  ["Draft"]=>
  string(1) " "
  ["Msgno"]=>
  string(4) "   1"
  ["MailDate"]=>
  string(26) "11-Apr-2014 01:27:57 +0000"
  ["Size"]=>
  string(3) "922"
  ["udate"]=>
  int(1397179677)
}
string(655) "Return-Path: <>
Delivery-Date: Fri, 11 Apr 2014 03:27:57 +0100
Received: from spamreport by localhost id 0MRpI7-1WRWOS48ML-00Skij for
        support@XXX.com (mailbox m51559649-71621086);
        Fri, 11 Apr 2014 03:27:57 +0100
From: =?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?=
Subject: Rapport quotidien du dossier Spam du compte email
        support@XXX.com
Date: Fri, 11 Apr 2014 03:27:57 +0100
To: <support@XXX.com>
Message-Id: <0MRpI7-1WRWOS48ML-00Skij@spamreport.1and1.fr>
Envelope-To: support@XXX.com
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

"
object(stdClass)#27 (13) {
  ["date"]=>
  string(31) "Fri, 11 Apr 2014 03:27:57 +0100"
  ["Date"]=>
  string(31) "Fri, 11 Apr 2014 03:27:57 +0100"
  ["subject"]=>
  string(72) "Rapport quotidien du dossier Spam du compte email support@XXX.com"
  ["Subject"]=>
  string(72) "Rapport quotidien du dossier Spam du compte email support@XXX.com"
  ["message_id"]=>
  string(46) "<0MRpI7-1WRWOS48ML-00Skij@spamreport.1and1.fr>"
  ["toaddress"]=>
  string(22) "support@XXX.com"
  ["to"]=>
  array(1) {
    [0]=>
    object(stdClass)#28 (2) {
      ["mailbox"]=>
      string(7) "support"
      ["host"]=>
      string(14) "XXX.com"
    }
  }
  ["fromaddress"]=>
  string(69) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?=@UNKNOWN"
  ["from"]=>
  array(1) {
    [0]=>
    object(stdClass)#29 (2) {
      ["mailbox"]=>
      string(61) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?="
      ["host"]=>
      string(7) "UNKNOWN"
    }
  }
  ["reply_toaddress"]=>
  string(69) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?=@UNKNOWN"
  ["reply_to"]=>
  array(1) {
    [0]=>
    object(stdClass)#30 (2) {
      ["mailbox"]=>
      string(61) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?="
      ["host"]=>
      string(7) "UNKNOWN"
    }
  }
  ["senderaddress"]=>
  string(69) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?=@UNKNOWN"
  ["sender"]=>
  array(1) {
    [0]=>
    object(stdClass)#31 (2) {
      ["mailbox"]=>
      string(61) "=?utf-8?q?D=C3=A9tection_de_spam_=3Cnoreply=401and1=2Efr=3E?="
      ["host"]=>
      string(7) "UNKNOWN"
    }
  }
}



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



--
Edit this bug report at https://bugs.php.net/bug.php?id=67207&edit=1


Thread (4 messages)

« previous php.bugs (#229614) next »