mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 11:30:55 +01:00
Work around mailparse bug (?) with messages that have no terminal newline
Summary: Under some unusual circumstances, mailparse appears to incorrectly discard the last line of some mail messages. Test Plan: - Constructed a raw mail with no terminal newline. - Piped it into `mail_receiver.php`. - Saw the last line vanish into the aether. - Applied patch; repeated; last line survived. Reviewers: btrahan, chad Reviewed By: chad Subscribers: chad, epriestley Differential Revision: https://secure.phabricator.com/D12494
This commit is contained in:
parent
d8ab5f594c
commit
80b23b21f3
1 changed files with 8 additions and 0 deletions
|
@ -111,6 +111,14 @@ class MimeMailParser {
|
||||||
* @param $data String
|
* @param $data String
|
||||||
*/
|
*/
|
||||||
public function setText($data) {
|
public function setText($data) {
|
||||||
|
// NOTE: This has been modified for Phabricator. If the input data does not
|
||||||
|
// end in a newline, Mailparse fails to include the last line in the mail
|
||||||
|
// body. This happens somewhere deep, deep inside the mailparse extension,
|
||||||
|
// so adding a newline here seems like the most straightforward fix.
|
||||||
|
if (!preg_match('/\n\z/', $data)) {
|
||||||
|
$data = $data."\n";
|
||||||
|
}
|
||||||
|
|
||||||
$this->resource = mailparse_msg_create();
|
$this->resource = mailparse_msg_create();
|
||||||
// does not parse incrementally, fast memory hog might explode
|
// does not parse incrementally, fast memory hog might explode
|
||||||
mailparse_msg_parse($this->resource, $data);
|
mailparse_msg_parse($this->resource, $data);
|
||||||
|
|
Loading…
Reference in a new issue