From: Craig Andrews Date: Tue, 2 Mar 2010 02:42:38 +0000 (-0500) Subject: Correctly handle the case when MIME/Type doesn't know what file extension a mime... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a0114f20066fb50b5f8074bb00db0b398ff7899a;p=quix0rs-gnu-social.git Correctly handle the case when MIME/Type doesn't know what file extension a mime type maps to --- diff --git a/classes/File.php b/classes/File.php index 189e04ce02..79a7d66813 100644 --- a/classes/File.php +++ b/classes/File.php @@ -169,7 +169,11 @@ class File extends Memcached_DataObject { require_once 'MIME/Type/Extension.php'; $mte = new MIME_Type_Extension(); - $ext = $mte->getExtension($mimetype); + try { + $ext = $mte->getExtension($mimetype); + } catch ( Exception $e) { + $ext = strtolower(preg_replace('/\W/', '', $mimetype)); + } $nickname = $profile->nickname; $datestamp = strftime('%Y%m%dT%H%M%S', time()); $random = strtolower(common_confirmation_code(32));