leahneukirchen / mblaze

Unix utilities to deal with Maildir
Other
451 stars 50 forks source link

mshow/mflow doesn’t display EBCDIC-encoded bodies correctly #146

Closed qsuscs closed 5 years ago

qsuscs commented 5 years ago

If you read this subject and ask yourself “What in the name of—?!”, yes, exactly. This is cursed and should really not be a real-world issue, but I still consider it a bug.

When invoked on a mail that contains EBCDIC-coded headers and body, mshow will decode and display the headers correctly; the body, however, not. I’m not really sure whether this is an issue with mshow or mflow.

Steps to reproduce: invoke mshow (with text/plain: mflow in .mblaze/filter) on this mail.

From: =?EBCDIC-INT?B?44iWlIGiQOKDiJWFiYSFmQ==?= <qsx@qsx.re>
To: =?EBCDIC-INT?B?44iWlIGiQOKDiJWFiYSFmQ==?= <qsx@qsx.re>
Date: Tue, 04 Dec 2018 16:55:15 +0100
Subject: =?EBCDIC-INT?B?44iJokCipIKRhYOjQImiQImVQMXCw8TJww==?=
Content-Type: text/plain; charset="EBCDIC-INT"
Content-Transfer-Encoding: base64
Message-ID: <F7A3S3POYB.3P9ZHF8WLUSKQ@coruscant.chaotikum.eu>

44iFQJikiYOSQIKZlqaVQIaWp0CRpJSXokCWpYWZQKOIhUCTgamoQISWh0sl

Results:

% mshow ./ebcdic-mail
From: Thomas Schneider <qsx@qsx.re>
Subject: This subject is in EBCDIC
To: Thomas Schneider <qsx@qsx.re>
Date: Tue, 04 Dec 2018 16:55:15 +0100 (14 minutes, 54 seconds ago)

--- 1: text/plain size=45 charset="EBCDIC-INT" render="mflow" ---
㈅@␛␘¤␛␉␛␃␛␒@␛␂␛␙␛␖¦␛␕@␛␆␛␖§@␛␑¤␛␔␛␗¢@␛␖¥␛␅␛␙@£␛␈␛␅@␛␓␛␁©¨@␛␄␛␖␛␇K%

Your results may differ based on your locale and whatnot.

Expected results: the body should display “The quick brown fox jumps over the lazy dog.”

leahneukirchen commented 5 years ago

Works for me:

% mshow ./ebcdic.msg 
From: Thomas Schneider <qsx@qsx.re>
Subject: This subject is in EBCDIC
To: Thomas Schneider <qsx@qsx.re>
Date: Tue, 04 Dec 2018 16:55:15 +0100 (1 hour, 5 minutes, 11 seconds ago)

--- 1: text/plain size=45 charset="EBCDIC-INT" render="mrecode | mflow -f" ---
The quick brown fox jumps over the lazy dog.

(I assume your libiconv can deal with EBCDIC? Try mshow -Fperhaps your mrecode is bad?)

leahneukirchen commented 5 years ago

Oh, now I see you use mflow without mrecode. That will be broken indeed. :)

leahneukirchen commented 5 years ago

Perhaps mrecode should be builtin to mshow, but it will need special code for dealing with text attachments then (e.g. we don't want to recode text/html beforehand).

leahneukirchen commented 5 years ago

Closing for now.

qsuscs commented 5 years ago

I just realized that as of commit 6710fd9 (which is older than this issue), this should not happen. Unless one uses filters: in that case, mshow does not convert its output to UTF-8. So indeed, when one uses e. g. mflow as filter for text/plain, mrecode should be added to the filter chain.

I’m not sure whether mshow should behave this way, but it does, anyway.