From: Florent Bruneau Date: Wed, 19 Mar 2008 16:42:18 +0000 (+0100) Subject: Workaround a bug of php 5.2.0+etch10 which has a fallback to text/plain X-Git-Tag: 1.8~1 X-Git-Url: http://git.polytechnique.org/?p=banana.git;a=commitdiff_plain;h=1886fdea373564ae6c355077b7d7adf49c880c7f Workaround a bug of php 5.2.0+etch10 which has a fallback to text/plain instead of application/octet-stream. Signed-off-by: Florent Bruneau --- diff --git a/banana/mimepart.inc.php b/banana/mimepart.inc.php index 6b0f399..743ced2 100644 --- a/banana/mimepart.inc.php +++ b/banana/mimepart.inc.php @@ -238,6 +238,9 @@ class BananaMimePart { if ($is_filename) { $type = mime_content_type($data); + if ($type == 'text/plain') { // XXX Workaround a bug of php 5.2.0+etch10 (fallback for mime_content_type is text/plain) + $type = preg_replace('/;.*/', '', trim(shell_exec('file -bi ' . escapeshellarg($data)))); + } } else { $arg = escapeshellarg($data); $type = preg_replace('/;.*/', '', trim(shell_exec("echo $arg | file -bi -")));