Changeset View
Changeset View
Standalone View
Standalone View
externals/mimemailparser/MimeMailParser.class.php
Context not available. | |||||
// end in a newline, Mailparse fails to include the last line in the mail | // end in a newline, Mailparse fails to include the last line in the mail | ||||
// body. This happens somewhere deep, deep inside the mailparse extension, | // body. This happens somewhere deep, deep inside the mailparse extension, | ||||
// so adding a newline here seems like the most straightforward fix. | // so adding a newline here seems like the most straightforward fix. | ||||
if (!preg_match('/\n\z/', $data)) { | if (!@preg_match('/\n\z/', $data)) { | ||||
$data = $data."\n"; | $data = $data."\n"; | ||||
} | } | ||||
Context not available. | |||||
$filename = $part['content-name']; | $filename = $part['content-name']; | ||||
$disposition = 'attachment'; | $disposition = 'attachment'; | ||||
} elseif (!in_array($part['content-type'], $non_attachment_types, true) | } elseif (!in_array($part['content-type'], $non_attachment_types, true) | ||||
&& substr($part['content-type'], 0, 10) !== 'multipart/' | && @substr($part['content-type'], 0, 10) !== 'multipart/' | ||||
) { | ) { | ||||
// if we cannot get it with getMessageBody, we assume it is an attachment | // if we cannot get it with getMessageBody, we assume it is an attachment | ||||
$disposition = 'attachment'; | $disposition = 'attachment'; | ||||
Context not available. | |||||
private function getPartHeaderFromText(&$part) { | private function getPartHeaderFromText(&$part) { | ||||
$start = $part['starting-pos']; | $start = $part['starting-pos']; | ||||
$end = $part['starting-pos-body']; | $end = $part['starting-pos-body']; | ||||
$header = substr($this->data, $start, $end-$start); | $header = @substr($this->data, $start, $end-$start); | ||||
return $header; | return $header; | ||||
} | } | ||||
/** | /** | ||||
Context not available. | |||||
private function getPartBodyFromText(&$part) { | private function getPartBodyFromText(&$part) { | ||||
$start = $part['starting-pos-body']; | $start = $part['starting-pos-body']; | ||||
$end = $part['ending-pos-body']; | $end = $part['ending-pos-body']; | ||||
$body = substr($this->data, $start, $end-$start); | $body = @substr($this->data, $start, $end-$start); | ||||
return $body; | return $body; | ||||
} | } | ||||
Context not available. | |||||
} | } | ||||
} else if ($this->data) { | } else if ($this->data) { | ||||
$attachment = $this->decode($this->getPartBodyFromText($part), $encoding); | $attachment = $this->decode($this->getPartBodyFromText($part), $encoding); | ||||
fwrite($temp_fp, $attachment, strlen($attachment)); | fwrite($temp_fp, $attachment, @strlen($attachment)); | ||||
} | } | ||||
fseek($temp_fp, 0, SEEK_SET); | fseek($temp_fp, 0, SEEK_SET); | ||||
} else { | } else { | ||||
Context not available. | |||||
* @param $encodingType The encoding type from the Content-Transfer-Encoding header of the part. | * @param $encodingType The encoding type from the Content-Transfer-Encoding header of the part. | ||||
*/ | */ | ||||
private function decode($encodedString, $encodingType) { | private function decode($encodedString, $encodingType) { | ||||
if (strtolower($encodingType) == 'base64') { | if (@strtolower($encodingType) == 'base64') { | ||||
return base64_decode($encodedString); | return base64_decode($encodedString); | ||||
} else if (strtolower($encodingType) == 'quoted-printable') { | } else if (@strtolower($encodingType) == 'quoted-printable') { | ||||
return quoted_printable_decode($encodedString); | return quoted_printable_decode($encodedString); | ||||
} else { | } else { | ||||
return $encodedString; | return $encodedString; | ||||
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