From: Jim Martens Date: Sat, 28 Jul 2012 12:12:59 +0000 (+0200) Subject: Fixes unterminated string literal problem. X-Git-Tag: 2.0.0_Beta_1~888^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cf614a4badb097b4b7ca8693b9c5ede045084dc7;p=GitHub%2FWoltLab%2FWCF.git Fixes unterminated string literal problem. --- diff --git a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php index 999d35534e..9da4836a7a 100644 --- a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php +++ b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php @@ -5,6 +5,7 @@ use wcf\system\exception\SystemException; use wcf\system\language\LanguageFactory; use wcf\system\SingletonFactory; use wcf\system\WCF; +use wcf\util\StringUtil; /** * Provides internationalization support for input fields. @@ -81,7 +82,8 @@ class I18nHandler extends SingletonFactory { public function readValues() { foreach ($this->elementIDs as $elementID) { if (isset($_POST[$elementID])) { - $this->plainValues[$elementID] = $_POST[$elementID]; + // you should trim the string before using it; prevents unwanted newlines + $this->plainValues[$elementID] = StringUtil::unifyNewlines(StringUtil::trim($_POST[$elementID])); continue; } @@ -90,7 +92,7 @@ class I18nHandler extends SingletonFactory { $this->i18nValues[$elementID] = array(); foreach ($_POST[$i18nElementID] as $languageID => $value) { - $this->i18nValues[$elementID][$languageID] = $value; + $this->i18nValues[$elementID][$languageID] = StringUtil::unifyNewlines(StringUtil::trim($value)); } continue; @@ -339,6 +341,10 @@ class I18nHandler extends SingletonFactory { else { if ($this->hasI18nValues($elementID)) { $i18nValues = $this->i18nValues[$elementID]; + // encoding the entries for javascript + foreach ($i18nValues as $languageID => $value) { + $i18nValues[$languageID] = StringUtil::encodeJS(StringUtil::unifyNewlines($value)); + } } else { $i18nValues = array(); @@ -358,7 +364,7 @@ class I18nHandler extends SingletonFactory { $this->elementOptions[$elementID]['packageID'] )); while ($row = $statement->fetchArray()) { - $i18nValues[$row['languageID']] = $row['languageItemValue']; + $i18nValues[$row['languageID']] = StringUtil::encodeJS(StringUtil::unifyNewlines($row['languageItemValue'])); } } else {