Type text/plain should not contain any null characters. Slightly
improve the type guesser by forcing an attachment with any null
characters to be application/octet-stream.
Note the type guesser could use much more improvement, but this is an
easy and obvious fix.
{
long hibin; /**< 8-bit characters */
long lobin; /**< unprintable 7-bit chars (eg., control chars) */
+ long nulbin; /**< null characters (0x0) */
long crlf; /**< `\r` and `\n` characters */
long ascii; /**< number of ascii chars */
long linemax; /**< length of the longest line in the file */
info->ascii++;
whitespace++;
}
+ else if (ch == 0)
+ {
+ info->nulbin++;
+ info->lobin++;
+ }
else if (ch < 32 || ch == 127)
info->lobin++;
else
if (!att->subtype)
{
- if (info->lobin == 0 || (info->lobin + info->hibin + info->ascii) / info->lobin >= 10)
+ if ((info->nulbin == 0) &&
+ (info->lobin == 0 || (info->lobin + info->hibin + info->ascii) / info->lobin >= 10))
{
/*
* Statistically speaking, there should be more than 10% "lobin"