From aeb2e282db49831510b1894204718a2a7d2409b7 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Thu, 25 Feb 2016 22:32:07 +0100 Subject: [PATCH] Commented on the mime extension matching regexp --- classes/File.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/classes/File.php b/classes/File.php index 171ba9942b..5294d82c24 100644 --- a/classes/File.php +++ b/classes/File.php @@ -264,7 +264,6 @@ class File extends Managed_DataObject */ static function guessMimeExtension($mimetype, $filename=null) { - $ext = null; try { // first see if we know the extension for our mimetype $ext = common_supported_mime_to_ext($mimetype); @@ -301,11 +300,11 @@ class File extends Managed_DataObject // If nothing else has given us a result, try to extract it from // the mimetype value (this turns .jpg to .jpeg for example...) $matches = array(); + // FIXME: try to build a regexp that will get jpeg from image/jpeg as well as json from application/jrd+json if (!preg_match('/\/([a-z0-9]+)/', mb_strtolower($mimetype), $matches)) { throw new Exception('Malformed mimetype: '.$mimetype); } - $ext = mb_strtolower($matches[1]); - return $ext; + return mb_strtolower($matches[1]); } /**