Improved handling of optional language items
authorAlexander Ebert <ebert@woltlab.com>
Sun, 15 Feb 2015 11:33:12 +0000 (12:33 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 15 Feb 2015 11:33:12 +0000 (12:33 +0100)
wcfsetup/install/files/lib/data/language/Language.class.php

index 5ac83f30d1b50a3b8574b1014ea7246007776577..ccfe9485945413e0fe5f05671bc68fce874f0926 100644 (file)
@@ -8,7 +8,7 @@ use wcf\system\WCF;
  * Represents a language.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2014 WoltLab GmbH
+ * @copyright  2001-2015 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage data.language
@@ -103,8 +103,12 @@ class Language extends DatabaseObject {
                        return $this->items[$item];
                }
                
-               // return plain variable
-               if ($optional) return '';
+               // do not output value if there was no match and the item looks like a valid language item
+               if ($optional && preg_match('~^([a-zA-Z0-9-_]+\.)+[a-zA-Z0-9-_]+$~', $item)) {
+                       return '';
+               }
+               
+               // return plain input
                return $item;
        }