From a0114f20066fb50b5f8074bb00db0b398ff7899a Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 1 Mar 2010 21:42:38 -0500 Subject: [PATCH] Correctly handle the case when MIME/Type doesn't know what file extension a mime type maps to --- classes/File.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)); -- 2.39.5