aboutsummaryrefslogtreecommitdiff
path: root/classes/File.php
diff options
context:
space:
mode:
authorMikael Nordfeldth <mmn@hethane.se>2016-01-12 13:46:25 +0100
committerMikael Nordfeldth <mmn@hethane.se>2016-01-12 13:46:25 +0100
commitb696fb4eb1f4c547bc9efbbef6b83b9291cf0608 (patch)
treecd8fd72691a221059aa71953b91f72088da57757 /classes/File.php
parent8c28e54ccccfdcdcfeac1817b68df0da5708f58c (diff)
downloadgnu-social-b696fb4eb1f4c547bc9efbbef6b83b9291cf0608.tar
gnu-social-b696fb4eb1f4c547bc9efbbef6b83b9291cf0608.zip
Mimetypes like image/svg+xml were misinterpreted when guessing
We don't really need the mb_ in mb_strtolower but what the heck, why not. I love Unicode.
Diffstat (limited to 'classes/File.php')
-rw-r--r--classes/File.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/classes/File.php b/classes/File.php
index 2390f848de..beb1f8f324 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -264,9 +264,13 @@ class File extends Managed_DataObject
$ext = common_supported_mime_to_ext($mimetype);
} catch (Exception $e) {
// We don't support this mimetype, but let's guess the extension
- $ext = substr(strrchr($mimetype, '/'), 1);
+ $matches = array();
+ if (!preg_match('/\/([a-z0-9]+)/', mb_strtolower($mimetype), $matches)) {
+ throw new Exception('Malformed mimetype: '.$mimetype);
+ }
+ $ext = $matches[1];
}
- return strtolower($ext);
+ return mb_strtolower($ext);
}
/**