A moment ago I sent 8 images as attachment with mutt.
Three were garbled on arrival.

As it turns out, five of the images were sent using MIME type
application/octet-strteam, and the corrupted ones using text/plain.
The images were similar, with similar names and structure,
so it looks like a random effect.
And indeed, the mutt source (sendlib.c, around line 1390) says

    if (info->lobin == 0 || (info->lobin + info->hibin + info->ascii)/ 
info->lobin >= 10)
    {
      /*
       * Statistically speaking, there should be more than 10% "lobin"
       * chars if this is really a binary file...
       */
      att->type = TYPETEXT;
      att->subtype = safe_strdup ("plain");
    }
    else
    {
      att->type = TYPEAPPLICATION;
      att->subtype = safe_strdup ("octet-stream");
    }

The first of the corrupted files had
lobin = 42448, hibin = 572036, ascii = 597706
for a quotient of 28.
Clearly, this 10% test is completely bogus.

More in particular, I think that a file is binary if it contains even
a single NUL byte.

What is the reason for this test?

Should I propose a patch?

Andries Brouwer


[The structure of the corruption was also funny: the files were full of
NUL bytes, but these were faithfully preserved. But there were a few
sequences 15 12 (octal), that were interpreted as CR LF
and converted to LF so that the 15 byte was lost.]

Reply via email to