Fixed bug #12827: Core labels need to be utf-8 before json_encode
authorSteffen Kamper <info@sk-typo3.de>
Sun, 29 Nov 2009 15:33:52 +0000 (15:33 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Sun, 29 Nov 2009 15:33:52 +0000 (15:33 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@6581 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/backend.php

index 27ebea2..c720006 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
 
 2009-11-29  Steffen Kamper  <info@sk-typo3.de>
 
+       * Fixed bug #12827: Core labels need to be utf-8 before json_encode
        * Fixed bug #12828: change language .js for ExtJS according to BE language (thanks to Stefano Cecere)
 
 2009-11-29  Francois Suter  <francois@typo3.org>
index 5715c3a..a82faf7 100644 (file)
@@ -349,50 +349,42 @@ class TYPO3backend {
                        $this->loginSecurityLevel = 'superchallenged';
                }
 
-               $this->js .= '
-       Ext.BLANK_IMAGE_URL = "' .
-                               // t3lib_div::locationHeaderUrl() will include '/typo3/' in the URL
-                               htmlspecialchars(t3lib_div::locationHeaderUrl('gfx/clear.gif')) .
-                               '";
-
-
-       TYPO3.configuration = ' . json_encode(array(
-               'siteUrl' => t3lib_div::getIndpEnv('TYPO3_SITE_URL'),
-               'PATH_typo3' => $pathTYPO3,
-               'PATH_typo3_enc' => rawurlencode($pathTYPO3),
-               'username' => htmlspecialchars($GLOBALS['BE_USER']->user['username']),
-               'uniqueID' => t3lib_div::shortMD5(uniqid('')),
-               'securityLevel' => $this->loginSecurityLevel,
-               'TYPO3_mainDir' => TYPO3_mainDir,
-               'pageModule' => $pageModule,
-               'condensedMode' => $GLOBALS['BE_USER']->uc['condensedMode'] ? 1 : 0 ,
-               'workspaceFrontendPreviewEnabled' => $GLOBALS['BE_USER']->workspace != 0 && !$GLOBALS['BE_USER']->user['workspace_preview'] ? 0 : 1,
-               'veriCode' => $GLOBALS['BE_USER']->veriCode(),
-               'denyFileTypes' => PHP_EXTENSIONS_DEFAULT,
-               'showRefreshLoginPopup' => isset($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) ? intval($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) : FALSE,
-       )) . ';
-       TYPO3.LLL = {
-                       core : ' . json_encode(array(
-               'waitTitle' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_logging_in') ,
-               'refresh_login_failed' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed'),
-               'refresh_login_failed_message' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed_message'),
-               'refresh_login_title' => sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_title'), htmlspecialchars($GLOBALS['BE_USER']->user['username'])),
-               'login_expired' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_expired'),
-               'refresh_login_username' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_username'),
-               'refresh_login_password' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_password'),
-               'refresh_login_emptyPassword' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_emptyPassword'),
-               'refresh_login_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_button'),
-               'refresh_logout_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_logout_button'),
-               'please_wait' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.please_wait'),
-               'be_locked' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.be_locked'),
-               'refresh_login_countdown_singular' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_countdown_singular'),
-               'refresh_login_countdown' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_countdown'),
-               'login_about_to_expire' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_about_to_expire'),
-               'login_about_to_expire_title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_about_to_expire_title'),
-               'refresh_login_refresh_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_refresh_button'),
-               'refresh_direct_logout_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_direct_logout_button'),
-       )) . ',
-               fileUpload: ' . json_encode(array(
+               $t3Configuration = array(
+                       'siteUrl' => t3lib_div::getIndpEnv('TYPO3_SITE_URL'),
+                       'PATH_typo3' => $pathTYPO3,
+                       'PATH_typo3_enc' => rawurlencode($pathTYPO3),
+                       'username' => htmlspecialchars($GLOBALS['BE_USER']->user['username']),
+                       'uniqueID' => t3lib_div::shortMD5(uniqid('')),
+                       'securityLevel' => $this->loginSecurityLevel,
+                       'TYPO3_mainDir' => TYPO3_mainDir,
+                       'pageModule' => $pageModule,
+                       'condensedMode' => $GLOBALS['BE_USER']->uc['condensedMode'] ? 1 : 0 ,
+                       'workspaceFrontendPreviewEnabled' => $GLOBALS['BE_USER']->workspace != 0 && !$GLOBALS['BE_USER']->user['workspace_preview'] ? 0 : 1,
+                       'veriCode' => $GLOBALS['BE_USER']->veriCode(),
+                       'denyFileTypes' => PHP_EXTENSIONS_DEFAULT,
+                       'showRefreshLoginPopup' => isset($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) ? intval($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) : FALSE,
+               );
+               $t3LLLcore = array(
+                       'waitTitle' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_logging_in') ,
+                       'refresh_login_failed' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed'),
+                       'refresh_login_failed_message' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed_message'),
+                       'refresh_login_title' => sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_title'), htmlspecialchars($GLOBALS['BE_USER']->user['username'])),
+                       'login_expired' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_expired'),
+                       'refresh_login_username' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_username'),
+                       'refresh_login_password' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_password'),
+                       'refresh_login_emptyPassword' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_emptyPassword'),
+                       'refresh_login_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_button'),
+                       'refresh_logout_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_logout_button'),
+                       'please_wait' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.please_wait'),
+                       'be_locked' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.be_locked'),
+                       'refresh_login_countdown_singular' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_countdown_singular'),
+                       'refresh_login_countdown' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_countdown'),
+                       'login_about_to_expire' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_about_to_expire'),
+                       'login_about_to_expire_title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_about_to_expire_title'),
+                       'refresh_login_refresh_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_refresh_button'),
+                       'refresh_direct_logout_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_direct_logout_button'),
+               );
+               $t3LLLfileUpload = array(
                        'windowTitle' => $GLOBALS['LANG']->getLL('fileUpload_windowTitle'),
                        'buttonSelectFiles' => $GLOBALS['LANG']->getLL('fileUpload_buttonSelectFiles'),
                        'buttonCancelAll' => $GLOBALS['LANG']->getLL('fileUpload_buttonCancelAll'),
@@ -419,7 +411,21 @@ class TYPO3backend {
                        'errorUploadFileValidation' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFileValidation'),
                        'errorUploadFileCancelled' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFileCancelled'),
                        'errorUploadStopped' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadStopped'),
-               )) . '};
+               );
+
+                       // Convert labels/settings back to UTF-8 since json_encode() only works with UTF-8:
+               if ($GLOBALS['LANG']->charSet !== 'utf-8') {
+                       $t3Configuration['username'] = $GLOBALS['LANG']->csConvObj->conv($t3Configuration['username'], $GLOBALS['LANG']->charSet, 'utf-8');
+                       $GLOBALS['LANG']->csConvObj->convArray($t3LLLcore, $GLOBALS['LANG']->charSet, 'utf-8');
+                       $GLOBALS['LANG']->csConvObj->convArray($t3LLLfileUpload, $GLOBALS['LANG']->charSet, 'utf-8');
+               }
+
+               $this->js .= '
+       TYPO3.configuration = ' . json_encode($t3Configuration) . ';
+       TYPO3.LLL = {
+               core : ' . json_encode($t3LLLcore) . ',
+               fileUpload: ' . json_encode($t3LLLfileUpload) . '
+       };
 
        /**
         * TypoSetup object.