mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-12 08:36:13 +01:00
Fix parsing of incoming mail with UTF-8 encoded headers
Summary: rPa76444a8e238f647dc96f756e6c88aa2fafcdbfe updated our 13 year old copy of the mimemailparser library. That included a behaviour change in the library not covered by Phorge code: The library now decodes MIME encoded UTF8 data in headers. Phorge passes that header to the `iconv_mime_decode()` PHP function which does not accept already encoded content. ``` EXCEPTION: (RuntimeException) iconv_mime_decode(): Detected an illegal character in input string at [<arcanist>/src/error/PhutilErrorHandler.php:273] arcanist(head=master, ref.master=29ca3df1122b), phorge(head=master, ref.master=6ec5c88bee24) #0 PhutilErrorHandler::handleError(integer, string, string, integer) #1 iconv_mime_decode(string, integer, string) called at [<arcanist>/src/utils/utils.php:1759] #2 phutil_decode_mime_header(string) called at [<phorge>/scripts/mail/mail_handler.php:64] ``` Closes T15960 Test Plan: * Have an email file called `tmp.mbox` with a UTF-8 encoded `From:` header. In `scripts/mail/mail_handler.php`, replace `file_get_contents('php://stdin')` with `file_get_contents('./tmp.mbox')`. Insert `echo $headers['subject']; echo "\n"; echo $headers['from'];` statements for debugging. Run `php ./mail_handler.php`. Reviewers: O1 Blessed Committers, taavi, valerio.bozzolan Reviewed By: O1 Blessed Committers, taavi, valerio.bozzolan Subscribers: taavi, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15960 Differential Revision: https://we.phorge.it/D25839
This commit is contained in:
parent
eb380f922c
commit
c589529155
1 changed files with 0 additions and 4 deletions
|
@ -57,10 +57,6 @@ foreach (array('text', 'html') as $part) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers = $parser->getHeaders();
|
$headers = $parser->getHeaders();
|
||||||
if (array_key_exists('subject', $headers)) {
|
|
||||||
$headers['subject'] = phutil_decode_mime_header($headers['subject']);
|
|
||||||
}
|
|
||||||
$headers['from'] = phutil_decode_mime_header($headers['from']);
|
|
||||||
|
|
||||||
if ($args->getArg('process-duplicates')) {
|
if ($args->getArg('process-duplicates')) {
|
||||||
$headers['message-id'] = Filesystem::readRandomCharacters(64);
|
$headers['message-id'] = Filesystem::readRandomCharacters(64);
|
||||||
|
|
Loading…
Reference in a new issue