3 ms·
Ok, I have a fun little UTF-7 story to share. At $work, we run a heavily patched OTRS for keeping track of our tickets, and have lots of systems automatically
by perlgeek 8y ago
Ok, I have a fun little UTF-7 story to share.
At $work, we run a heavily patched OTRS for keeping track of our tickets, and have lots of systems automatically sending cron and other status mails to it (bad, I know).
We got a bug report that the recipient email was displayed as Mojibake, something like blabla+⻧⻯⻱@ourdomain.net
After digging into the source email and the OTRS code base, I found the problem:
Some shitty MUA years ago failed to properly encode email headers, and sent 8-bit "Subject: " headers. To deal with that, OTRS had a workaround that tried to decode all (!) headers with the encoding specified in the Content-Encoding header, with a fallback to ASCII or Latin-1 if the decoding failed.
Now, a pretty old Windows system or application sent UTF-7 encoded emails to something like blabla+autoreply=no+more=stuff-here@ourdomain.net, and OTRS successfully decoded the 'To:' header as UTF-7. And since it's not ASCII compatible, it turned it into gibberish.
The "fix" was to only do the header decoding if the declared encoding is ASCII compatible.
The code still seems to be in OTRS today: https://github.com/OTRS/otrs/blob/rel-6_0_14/Kernel/System/Encode.pm#L353 https://github.com/OTRS/otrs/blob/rel-6_0_14/Kernel/System/E...