Fixed formatting of allowed file extensions
authorMarcel Werk <burntime@woltlab.com>
Tue, 13 Aug 2013 22:03:43 +0000 (00:03 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 13 Aug 2013 22:03:43 +0000 (00:03 +0200)
wcfsetup/install/files/lib/system/attachment/AttachmentHandler.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index c845a5d09566b47eb401f045363f6508eb51f15a..ec42fbf94f28a010787860987928d5842176386e 100644 (file)
@@ -165,6 +165,32 @@ class AttachmentHandler implements \Countable {
                return $this->processor->getAllowedExtensions();
        }
        
+       /**
+        * Returns a formatted list of the allowed file extensions.
+        * 
+        * @return array<string>
+        */
+       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()
         */
index d44284cd9e7d62c9c3c51a6732ca32e981e63def..39daaee1c1472093aa883df0ae97d96b1c940c73 100644 (file)
@@ -1331,7 +1331,7 @@ Wenn Sie unter <em>System -&gt; Optionen -&gt; Allgemein -&gt; E-Mails</em> alle
                <item name="wcf.attachment.upload.error.uploadFailed"><![CDATA[Beim Hochladen der Datei ist ein unbekannter Fehler aufgetreten.]]></item>
                <item name="wcf.attachment.upload.limits"><![CDATA[Maximale Anzahl an Dateianhängen: {#$attachmentHandler->getMaxCount()}<br />
 Maximale Dateigröße: {@$attachmentHandler->getMaxSize()|filesize}<br />
-Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getAllowedExtensions()}]]></item>
+Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getFormattedAllowedExtensions()}]]></item>
                <item name="wcf.attachment.insert"><![CDATA[In Text einfügen]]></item>
                <item name="wcf.attachment.delete.sure"><![CDATA[Wollen Sie den Dateianhang wirklich löschen?]]></item>
                <item name="wcf.attachment.filename"><![CDATA[Dateiname]]></item>
index 2f29174e189d9328249b699eb223da15d857d280..d6ff8cbe932e114824ed626ad061949f30083f2f 100644 (file)
@@ -1330,7 +1330,7 @@ You can define the default sender in <em>System -&gt; Options -&gt; General -&gt
                <item name="wcf.attachment.upload.error.uploadFailed"><![CDATA[An unknown error occured during upload.]]></item>
                <item name="wcf.attachment.upload.limits"><![CDATA[Maximum number of attachments: {#$attachmentHandler->getMaxCount()}<br />
 Maximum file size: {@$attachmentHandler->getMaxSize()|filesize}<br />
-Allowed extensions: {', '|implode:$attachmentHandler->getAllowedExtensions()}]]></item>
+Allowed extensions: {', '|implode:$attachmentHandler->getFormattedAllowedExtensions()}]]></item>
                <item name="wcf.attachment.insert"><![CDATA[Insert into message]]></item>
                <item name="wcf.attachment.filename"><![CDATA[Filename]]></item>
                <item name="wcf.attachment.uploadTime"><![CDATA[Upload Time]]></item>