[BUGFIX] Don't convert labels for charsets in Extbase/Fluid 11/46711/2
authorBenni Mack <benni@typo3.org>
Tue, 16 Feb 2016 13:01:45 +0000 (14:01 +0100)
committerBenni Mack <benni@typo3.org>
Tue, 16 Feb 2016 20:01:37 +0000 (21:01 +0100)
When Extbase/Fluid initially were introduced, it was possible
to store non-UTF8-data in the database. A charset array within
CharsetConverter checked if a special language (e.g. russian)
had its own character set. The LocalizationUtility then converted
the value from the original character set to utf-8 which is not
needed anymore, as every input data is expected to be UTF-8.

Labels coming from TypoScript are now expected to be UTF-8  as well.

Resolves: #73487
Releases: master, 7.6
Change-Id: I2292c587b7709257d8efcb58f4e5c0a4c191c944
Reviewed-on: https://review.typo3.org/46711
Reviewed-by: Sebastian Fischer <typo3@evoweb.de>
Tested-by: Sebastian Fischer <typo3@evoweb.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php

index 74a40c2..0d48bb5 100644 (file)
@@ -14,7 +14,6 @@ namespace TYPO3\CMS\Extbase\Utility;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Charset\CharsetConverter;
 use TYPO3\CMS\Core\Localization\Locales;
 use TYPO3\CMS\Core\Localization\LocalizationFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -51,13 +50,6 @@ class LocalizationUtility
     protected static $LOCAL_LANG_UNSET = array();
 
     /**
-     * Local Language content charset for individual labels (overriding)
-     *
-     * @var array
-     */
-    protected static $LOCAL_LANG_charset = array();
-
-    /**
      * Key of the language to use
      *
      * @var string
@@ -99,9 +91,6 @@ class LocalizationUtility
             ) {
                 // Local language translation for key exists
                 $value = self::$LOCAL_LANG[$extensionName][self::$languageKey][$key][0]['target'];
-                if (!empty(self::$LOCAL_LANG_charset[$extensionName][self::$languageKey][$key])) {
-                    $value = self::convertCharset($value, self::$LOCAL_LANG_charset[$extensionName][self::$languageKey][$key]);
-                }
             } elseif (!empty(self::$alternativeLanguageKeys)) {
                 $languages = array_reverse(self::$alternativeLanguageKeys);
                 foreach ($languages as $language) {
@@ -110,9 +99,6 @@ class LocalizationUtility
                     ) {
                         // Alternative language translation for key exists
                         $value = self::$LOCAL_LANG[$extensionName][$language][$key][0]['target'];
-                        if (!empty(self::$LOCAL_LANG_charset[$extensionName][$language][$key])) {
-                            $value = self::convertCharset($value, self::$LOCAL_LANG_charset[$extensionName][$language][$key]);
-                        }
                         break;
                     }
                 }
@@ -230,8 +216,6 @@ class LocalizationUtility
             return;
         }
         self::$LOCAL_LANG_UNSET[$extensionName] = array();
-        /** @var CharsetConverter $charsetConverter */
-        $charsetConverter = GeneralUtility::makeInstance(CharsetConverter::class);
         foreach ($frameworkConfiguration['_LOCAL_LANG'] as $languageKey => $labels) {
             if (!(is_array($labels) && isset(self::$LOCAL_LANG[$extensionName][$languageKey]))) {
                 continue;
@@ -242,7 +226,6 @@ class LocalizationUtility
                     if ($labelValue === '') {
                         self::$LOCAL_LANG_UNSET[$extensionName][$languageKey][$labelKey] = '';
                     }
-                    self::$LOCAL_LANG_charset[$extensionName][$languageKey][$labelKey] = $charsetConverter->charSetArray[$languageKey];
                 } elseif (is_array($labelValue)) {
                     $labelValue = self::flattenTypoScriptLabelArray($labelValue, $labelKey);
                     foreach ($labelValue as $key => $value) {
@@ -285,24 +268,6 @@ class LocalizationUtility
     }
 
     /**
-     * Converts a string from the specified character set to the current.
-     * The current charset is defined by the TYPO3 mode.
-     *
-     * @param string $value string to be converted
-     * @param string $charset The source charset
-     * @return string converted string
-     */
-    protected static function convertCharset($value, $charset)
-    {
-        if (TYPO3_MODE === 'FE') {
-            return self::getTypoScriptFrontendController()->csConv($value, $charset);
-        } else {
-            $convertedValue = self::getLanguageService()->csConvObj->conv($value, self::getLanguageService()->csConvObj->parse_charset($charset), 'utf-8', 1);
-            return $convertedValue !== null ? $convertedValue : $value;
-        }
-    }
-
-    /**
      * Returns instance of the configuration manager
      *
      * @return \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface