Changeset View
Changeset View
Standalone View
Standalone View
scripts/mail/mail_handler.php
Context not available. | |||||
// Some day, we could take a shot at cleaning this up. | // Some day, we could take a shot at cleaning this up. | ||||
if ($argc > 1) { | if ($argc > 1) { | ||||
foreach (array_slice($argv, 1) as $arg) { | foreach (array_slice($argv, 1) as $arg) { | ||||
if (!preg_match('/^-/', $arg)) { | if (!@preg_match('/^-/', $arg)) { | ||||
$_SERVER['PHABRICATOR_ENV'] = $arg; | $_SERVER['PHABRICATOR_ENV'] = $arg; | ||||
break; | break; | ||||
} | } | ||||
Context not available. | |||||
foreach (array('text', 'html') as $part) { | foreach (array('text', 'html') as $part) { | ||||
$part_body = $parser->getMessageBody($part); | $part_body = $parser->getMessageBody($part); | ||||
if (strlen($part_body) && !phutil_is_utf8($part_body)) { | if (@strlen($part_body) && !phutil_is_utf8($part_body)) { | ||||
$part_headers = $parser->getMessageBodyHeaders($part); | $part_headers = $parser->getMessageBodyHeaders($part); | ||||
if (!is_array($part_headers)) { | if (!is_array($part_headers)) { | ||||
$part_headers = array(); | $part_headers = array(); | ||||
} | } | ||||
$content_type = idx($part_headers, 'content-type'); | $content_type = idx($part_headers, 'content-type'); | ||||
if (preg_match('/charset="(.*?)"/', $content_type, $matches) || | if (@preg_match('/charset="(.*?)"/', $content_type, $matches) || | ||||
preg_match('/charset=(\S+)/', $content_type, $matches)) { | @preg_match('/charset=(\S+)/', $content_type, $matches)) { | ||||
$part_body = phutil_utf8_convert($part_body, 'UTF-8', $matches[1]); | $part_body = phutil_utf8_convert($part_body, 'UTF-8', $matches[1]); | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
$attachments = array(); | $attachments = array(); | ||||
foreach ($parser->getAttachments() as $attachment) { | foreach ($parser->getAttachments() as $attachment) { | ||||
if (preg_match('@text/(plain|html)@', $attachment->getContentType()) && | if (@preg_match('@text/(plain|html)@', $attachment->getContentType()) && | ||||
$attachment->getContentDisposition() == 'inline') { | $attachment->getContentDisposition() == 'inline') { | ||||
// If this is an "inline" attachment with some sort of text content-type, | // If this is an "inline" attachment with some sort of text content-type, | ||||
// do not treat it as a file for attachment. MimeMailParser already picked | // do not treat it as a file for attachment. MimeMailParser already picked | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0