[BUGFIX] resolveDefaultEncoding with wrong fallback
authorMarkus Günther <mail@markus-guenther.de>
Fri, 20 Jul 2012 17:33:23 +0000 (19:33 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 21 Jul 2012 17:35:17 +0000 (19:35 +0200)
Since TYPO3 4.7 the forceCharset configuration is deprecated. The class
Tx_Fluid_Core_Compiler_AbstractCompiledTemplate still uses the value
configured value $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'].
This patch removes this handling and always sets UTF-8 if no other
default charset is set.

Change-Id: I66b9368ad029326c2e26f4e004483d8b4b18ebe2
Resolves: #37929
Releases: 6.0
Reviewed-on: http://review.typo3.org/12937
Reviewed-by: Tymoteusz Motylewski
Tested-by: Tymoteusz Motylewski
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/fluid/Classes/Core/Compiler/AbstractCompiledTemplate.php
typo3/sysext/fluid/Tests/Unit/Core/Compiler/AbstractCompiledTemplateTest.php [new file with mode: 0644]

index af68983..bc38425 100644 (file)
@@ -91,17 +91,10 @@ abstract class Tx_Fluid_Core_Compiler_AbstractCompiledTemplate implements Tx_Flu
         * @internal
         */
        static public function resolveDefaultEncoding() {
-               if (self::$defaultEncoding === NULL) {
-                       if (TYPO3_MODE === 'BE') {
-                               self::$defaultEncoding = strtoupper($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']);
-                       } else {
-                               self::$defaultEncoding = strtoupper($GLOBALS['TSFE']->renderCharset);
-                       }
-                       if (self::$defaultEncoding === NULL) {
-                               self::$defaultEncoding = 'UTF-8';
-                       }
+               if (static::$defaultEncoding === NULL) {
+                       static::$defaultEncoding = 'UTF-8';
                }
-               return self::$defaultEncoding;
+               return static::$defaultEncoding;
        }
 
 }
diff --git a/typo3/sysext/fluid/Tests/Unit/Core/Compiler/AbstractCompiledTemplateTest.php b/typo3/sysext/fluid/Tests/Unit/Core/Compiler/AbstractCompiledTemplateTest.php
new file mode 100644 (file)
index 0000000..8018d49
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Markus Günther <mail@markus-guenther.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for AbstractCompilerTemplate
+ *
+ */
+class Tx_Fluid_Tests_Unit_Core_Compiler_AbstractCompilerTemplateTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
+
+       /**
+        * @test
+        */
+       public function resolveDefaultEncodingWillBeSetToUtf8IfNotSet() {
+               $this->assertSame('UTF-8', Tx_Fluid_Core_Compiler_AbstractCompiledTemplate::resolveDefaultEncoding());
+       }
+
+       /**
+        * @test
+        */
+       public function isDefaultEncodingIsSetThanDefaultEncodingWillReturned() {
+               $className = uniqid('Tx_Fluid_Core_Compiler_AbstractCompiledTemplate');
+               eval(
+                       'abstract class ' . $className . ' extends Tx_Fluid_Core_Compiler_AbstractCompiledTemplate {' .
+                       '  static protected $defaultEncoding = \'ISO-8859-1\';' .
+                       '}'
+               );
+               $this->assertSame('ISO-8859-1', $className::resolveDefaultEncoding());
+       }
+}
+?>
\ No newline at end of file