From: Marcel Werk Date: Tue, 13 Aug 2013 22:03:43 +0000 (+0200) Subject: Fixed formatting of allowed file extensions X-Git-Tag: 2.0.0_Beta_7~26 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0fe57ed7ec1fda8457b00776335ff80840c5e930;p=GitHub%2FWoltLab%2FWCF.git Fixed formatting of allowed file extensions --- diff --git a/wcfsetup/install/files/lib/system/attachment/AttachmentHandler.class.php b/wcfsetup/install/files/lib/system/attachment/AttachmentHandler.class.php index c845a5d095..ec42fbf94f 100644 --- a/wcfsetup/install/files/lib/system/attachment/AttachmentHandler.class.php +++ b/wcfsetup/install/files/lib/system/attachment/AttachmentHandler.class.php @@ -165,6 +165,32 @@ class AttachmentHandler implements \Countable { return $this->processor->getAllowedExtensions(); } + /** + * Returns a formatted list of the allowed file extensions. + * + * @return array + */ + public function getFormattedAllowedExtensions() { + $extensions = $this->getAllowedExtensions(); + + // sort + sort($extensions); + + // check wildcards + for ($i = 0, $j = count($extensions); $i < $j; $i++) { + if (strpos($extensions[$i], '*') !== false) { + for ($k = $j - 1; $k > $i; $k--) { + if (preg_match('/^'.str_replace('\*', '.*', preg_quote($extensions[$i], '/')).'$/i', $extensions[$k])) { + array_splice($extensions, $k, 1); + $j--; + } + } + } + } + + return $extensions; + } + /** * @see wcf\system\attachment\IAttachmentObjectType::getMaxCount() */ diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index d44284cd9e..39daaee1c1 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1331,7 +1331,7 @@ Wenn Sie unter System -> Optionen -> Allgemein -> E-Mails alle getMaxCount()}
Maximale Dateigröße: {@$attachmentHandler->getMaxSize()|filesize}
-Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getAllowedExtensions()}]]>
+Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getFormattedAllowedExtensions()}]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 2f29174e18..d6ff8cbe93 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1330,7 +1330,7 @@ You can define the default sender in System -> Options -> General -> getMaxCount()}
Maximum file size: {@$attachmentHandler->getMaxSize()|filesize}
-Allowed extensions: {', '|implode:$attachmentHandler->getAllowedExtensions()}]]>
+Allowed extensions: {', '|implode:$attachmentHandler->getFormattedAllowedExtensions()}]]>