-
-
Notifications
You must be signed in to change notification settings - Fork 178
Description
Describe the bug
Version 4.1.2
When parsing an email with this library I sometimes get the following message for parsing emails that are probably not formatted correctly.
Basically a part of the email is used for header parsing. Internally, php-imap splits the content into rows, checks if it contains the ":" symbol and uses the left part as the key, as far as I can see.
However there is one line in an email example I have, that looks like this: 0:30):
.
This causes $key in the Header::rfc822_parse_headers
to be 0. The switch
operator in PHP uses the ==
operator internally. Since 0 == "string"
results to true
, PHP jumps into the sender
case (breaks are missing for the previous cases). This causes an incorrect sender to be set for the mail.
This again then causes the application to crash when calling $attribute->__toString
as the values
property contains an object of type stdClass
that is not string serializable.
The resulting error is the following:
In Attribute.php line 53:
Object of class stdClass could not be converted to string
Used config
I dont this this is required.
Code to Reproduce
Unfortunately I have to black out most of the email. I hope the following mail part is sufficient for reproducing the issue. You can see line 18 starting with the problematic string:
------=_NextPart_001_0273_01D69722.AE8639E0
Content-Type: text/html;
type="multipart/alternative";
boundary="_005_MN2PR19MB3343AA1352A16FB60C76F8E7FD320MN2PR19MB3343namp_";
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
</head>
<body lang=3D"DE" link=3D"#0563C1" vlink=3D"#954F72">
<ul style=3D"margin-top:0cm" type=3D"disc">
<li class=3D"MsoListParagraphCxSpLast" =
style=3D"margin-left:0cm;mso-add-space:auto;mso-list:l0 level1 lfo3">
<span style=3D"font-family:"Calibri",sans-serif">K=C3=B6nntet =
ihr bitte noch folgendes XXXXX Wordmark direkt am Anfang des Videos =
einbauen, wenn xxxx die xxxx mit xxxx ank=C3=BCndigt (ca. Minute =
0:30):
</li></ul>
</body>
</html>
Expected behavior
In case the key is 0
, the switch operation should not go into the sender
case.
I think the easiest solution here is to use the if
operation with triple equals to check for identity, instead of using the unsafe switch case.