zbateson / mail-mime-parser

An email parser written in PHP
https://mail-mime-parser.org/
BSD 2-Clause "Simplified" License
441 stars 56 forks source link

Fixed null to string warnings in MimePart->getContentType() #199

Closed zacek closed 1 year ago

zacek commented 1 year ago

MimePart::getContentType() applies strtolower() on the result of getHeaderValue(). However, this result can be null even though the default value is provided as the default value is not used if the header is present but empty:

Content-Type:

In such cases, the result is null and PHP 8.1 complains:

strtolower(): Passing null to parameter #1 ($string) of type string is deprecated

My fix applies the default value even if the header is present but empty as in the example above.

zbateson commented 1 year ago

Wonderful, thank you!