Compare commits

..

No commits in common. "master" and "v0.5.3" have entirely different histories.

2 changed files with 11 additions and 52 deletions

View file

@ -100,14 +100,12 @@ class Attachment
try {
$hObject = imap_rfc822_parse_headers($header);
if (property_exists($hObject, 'subject')) {
$subject = MIME::decode($hObject->subject, Message::$charset);
$subject = preg_replace('#\s+#', ' ', $subject);
$subject = preg_replace('#^(.{0,50})#u', '$1', $subject);
$subject = MIME::decode($hObject->subject, Message::$charset);
$subject = preg_replace('#\s+#', ' ', $subject);
$subject = preg_replace('#^(.{0,50})#u', '$1', $subject);
if ($subject) {
$this->filename = $subject . '.eml';
}
if ($subject) {
$this->filename = $subject . '.eml';
}
} catch (\Throwable $e) {
@ -118,25 +116,13 @@ class Attachment
$parameters = Message::getParametersFromStructure($structure);
// quick fix for Content-Disposition extended notation
// name*0*=UTF-8''%D0%A...
// name*1*=%D0%B8...
// etc
if (!empty($parameters['filename*'])) {
$this->setFileName($parameters['filename*']);
} elseif (!empty($parameters['name*'])) {
$this->setFileName($parameters['name*']);
}
if (!empty($parameters['filename'])) {
$this->setFileName($parameters['filename']);
} elseif (!empty($parameters['name'])) {
$this->setFileName($parameters['name']);
}
if (property_exists($structure, 'bytes')) {
$this->size = $structure->bytes;
}
$this->size = $structure->bytes;
$this->mimeType = Message::typeIdToString($structure->type);

View file

@ -249,15 +249,9 @@ class Message
return false;
if (property_exists($messageOverview, 'subject')) {
$this->subject = MIME::decode($messageOverview->subject, self::$charset);
}
if (property_exists($messageOverview, 'date') && null !== $messageOverview->date) {
$this->date = strtotime($messageOverview->date);
}
$this->size = $messageOverview->size;
$this->subject = MIME::decode($messageOverview->subject, self::$charset);
$this->date = strtotime($messageOverview->date);
$this->size = $messageOverview->size;
foreach (self::$flagTypes as $flag)
$this->status[$flag] = ($messageOverview->$flag == 1);
@ -387,7 +381,7 @@ class Message
public function getStructure($forceReload = false)
{
if ($forceReload || !isset($this->structure)) {
$this->structure = @imap_fetchstructure($this->imapStream, $this->uid, FT_UID);
$this->structure = imap_fetchstructure($this->imapStream, $this->uid, FT_UID);
}
return $this->structure;
@ -538,23 +532,8 @@ class Message
*/
protected function processStructure($structure, $partIdentifier = null)
{
if (!$structure) {
return;
}
$parameters = self::getParametersFromStructure($structure);
// quick fix for Content-Disposition extended notation
// name*0*=UTF-8''%D0%A...
// name*1*=%D0%B8...
// etc
if (empty($parameters['name']) && !empty($parameters['name*'])) {
$parameters['name'] = $parameters['name*'];
}
if (empty($parameters['filename']) && !empty($parameters['filename*'])) {
$parameters['filename'] = $parameters['filename*'];
}
if (!empty($parameters['name']) || !empty($parameters['filename'])) {
$attachment = new Attachment($this, $structure, $partIdentifier);
$this->attachments[] = $attachment;
@ -764,13 +743,7 @@ class Message
foreach ($addresses as $address) {
if (property_exists($address, 'mailbox') && $address->mailbox != 'undisclosed-recipients') {
$currentAddress = array();
$host = '';
if (property_exists($address, 'host')) {
$host = $address->host;
}
$currentAddress['address'] = $address->mailbox . '@' . $host;
$currentAddress['address'] = $address->mailbox . '@' . $address->host;
if (isset($address->personal)) {
$currentAddress['name'] = MIME::decode($address->personal, self::$charset);
}