Merge pull request #6 from iyzoer/warning-fixes

[fix] add subject property check
This commit is contained in:
Akolzin Dmitry 2024-02-06 09:40:10 +03:00 committed by GitHub
commit 40025f2dea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -100,12 +100,14 @@ class Attachment
try { try {
$hObject = imap_rfc822_parse_headers($header); $hObject = imap_rfc822_parse_headers($header);
$subject = MIME::decode($hObject->subject, Message::$charset); if (property_exists($hObject, 'subject')) {
$subject = preg_replace('#\s+#', ' ', $subject); $subject = MIME::decode($hObject->subject, Message::$charset);
$subject = preg_replace('#^(.{0,50})#u', '$1', $subject); $subject = preg_replace('#\s+#', ' ', $subject);
$subject = preg_replace('#^(.{0,50})#u', '$1', $subject);
if ($subject) { if ($subject) {
$this->filename = $subject . '.eml'; $this->filename = $subject . '.eml';
}
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {