Page MenuHomePhorge

Fix parsing of incoming mail with UTF-8 encoded headers
ClosedPublic

Authored by aklapper on Nov 26 2024, 13:47.

Details

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.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

taavi subscribed.

Works on my machine!

(Sorry I cannot test now) Does the test plan work with just this?

php ./mail_handler.php < ./tmp.mbox

I tried to prepare a unit test but it's not working. But yes the patch itself seems to work thanks

This revision is now accepted and ready to land.Tue, Dec 3, 12:01
3tayesh added a reviewer: aklapper.
3tayesh changed the visibility from "Public (No Login Required)" to "3tayesh (Aqazade)".
3tayesh changed the edit policy from "All Users" to "3tayesh (Aqazade)".
Policy changed the edit policy from "3tayesh (Aqazade)" to "avivey (Aviv Eyal)".
avivey changed the visibility from "avivey (Aviv Eyal)" to "Public (No Login Required)".Tue, Dec 3, 16:17
avivey changed the edit policy from "avivey (Aviv Eyal)" to "All Users".
avivey subscribed.

@3tayesh Please don't do that again.

MacFan4000 edited reviewers, added: 3tayesh; removed: aklapper.
MacFan4000 removed a reviewer: aklapper.
MacFan4000 edited reviewers, added: Blessed Committers; removed: 3tayesh.
MacFan4000 edited subscribers, added: taavi, tobiaswiese, valerio.bozzolan, Cigaryno; removed: avivey.