Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad parsing of non-standard headers leading to getFrom() returning string #35

Closed
itkfm opened this issue Oct 23, 2020 · 1 comment
Closed
Labels
bug Something isn't working validated

Comments

@itkfm
Copy link

itkfm commented Oct 23, 2020

Describe the bug
Message::getFrom() returns a string instead of an object for mails with such a header:

From: "Facebook" <notification@facebookmail.com>
To: "…" <…>
Subject: …
Date: Fri, 1 Oct 2020 01:01:01 +0200
Message-ID: <…@facebookmail.com>
MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_…"
X-Priority: 3
X-Mailer: ZuckMail [version 1.00]
Thread-Index: …==
X-Facebook: from 2401:db00:321c:e0b:face:0:170:0 ([MTI3LjAuMC4x]) 
	by www.facebook.com with HTTPS (ZuckMail);
X-Facebook-Notify: msg; from=123456789012345; t=cid.c.…:…; mailid=…
X-FACEBOOK-PRIORITY: 0
X-Auto-Response-Suppress: All

To Reproduce
Steps to reproduce the behavior:

  1. Fetch a mail like the above one
    // […]
    $folders = $c->getFolders();
    foreach ($folders as $folder) {
        $msgs = $folder->messages();
        $msgs = $msgs->setFetchBody(false);
        $mails = $msgs->all()->get();
        foreach ($mails as $mail) {
            var_dump($mail->getFrom());
  2. you'll get
    string(15) "123456789012345"

Expected behavior

[0]=>
  object(stdClass)#1234 (5) {
    ["personal"]=>
    string(35) "Facebook"
    ["mailbox"]=>
    string(5) "notification"
    ["host"]=>
    string(8) "facebookmail.com"
    ["mail"]=>
    string(14) "notification@facebookmail.com"
    ["full"]=>
    string(52) "Facebook <notification@facebookmail.com>"
  }
}

Desktop:

  • OS: GNU/Linux
  • PHP: 7.4.3
@Webklex Webklex added bug Something isn't working validating validated and removed validating labels Oct 23, 2020
@Webklex
Copy link
Owner

Webklex commented Oct 23, 2020

Hi @itkfm ,
thanks for your excellent and well written report.

I was able to reproduce the problem and identified Header::extractHeaderExtensions() as the problematic method which "overwrites" the from header.

The "from" found in X-Facebook-Notify: msg; from=123456789012345; t=cid.c.…:…; mailid=… overwrites the original from.

Best regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working validated
Projects
None yet
Development

No branches or pull requests

2 participants