diff --git a/lib/unknownextensionmimeexception.php b/lib/unknownextensionmimeexception.php new file mode 100644 index 0000000000..faa6e9cf25 --- /dev/null +++ b/lib/unknownextensionmimeexception.php @@ -0,0 +1,26 @@ + + * @license https://www.gnu.org/licenses/agpl-3.0.html + * @link https://gnu.io/social + */ + +class UnknownExtensionMimeException extends ServerException +{ + public function __construct($ext) + { + // TRANS: We accept the file type (we probably just accept all files) + // TRANS: but don't know the file extension for it. %1$s is the extension. + $msg = sprintf(_('Unknown MIME type for file extension: %1$s'), _ve($ext)); + + parent::__construct($msg); + } +} diff --git a/lib/unknownmimeextensionexception.php b/lib/unknownmimeextensionexception.php index 0937467d07..fbc3a67742 100644 --- a/lib/unknownmimeextensionexception.php +++ b/lib/unknownmimeextensionexception.php @@ -17,14 +17,11 @@ if (!defined('GNUSOCIAL')) { exit(1); } class UnknownMimeExtensionException extends ServerException { - public function __construct($msg=null) + public function __construct($mimetype) { - if ($msg === null) { - // TRANS: We accept the file type (we probably just accept all files) - // TRANS: but don't know the file extension for it. - $msg = _('Supported mimetype but unknown extension relation.'); - } - + // TRANS: We accept the file type (we probably just accept all files) + // TRANS: but don't know the file extension for it. + $msg = sprintf(_('Supported mimetype but unknown extension relation: %1$s'), _ve($mimetype)); parent::__construct($msg); } } diff --git a/lib/util.php b/lib/util.php index 8d95ec2305..846605bc7f 100644 --- a/lib/util.php +++ b/lib/util.php @@ -2000,7 +2000,7 @@ function common_supported_ext_to_mime($fileext) $supported = common_config('attachments', 'supported'); if ($supported === true) { - throw new ServerException('Supported extension but unknown mimetype relation.'); + throw new UnknownExtensionMimeException($fileext); } foreach($supported as $type => $ext) { if ($ext === $fileext) { @@ -2016,7 +2016,7 @@ function common_supported_mime_to_ext($mimetype) { $supported = common_config('attachments', 'supported'); if ($supported === true) { - throw new UnknownMimeExtensionException(); + throw new UnknownMimeExtensionException($mimetype); } foreach($supported as $type => $ext) { if ($mimetype === $type) {