diff --git a/typo3/sysext/core/Classes/Encoder/JavaScriptEncoder.php b/typo3/sysext/core/Classes/Encoder/JavaScriptEncoder.php index dacd7b9b69bafc5b8c2cb075a54e024c18903baa..4dd2b46449d9da8b30e34adf663286f4c3be3b10 100644 --- a/typo3/sysext/core/Classes/Encoder/JavaScriptEncoder.php +++ b/typo3/sysext/core/Classes/Encoder/JavaScriptEncoder.php @@ -22,6 +22,7 @@ namespace TYPO3\CMS\Core\Encoder; * It encodes all characters except alphanumericals and the immune characters to a hex representation. * @copyright 2009-2010 The OWASP Foundation * @link http://www.owasp.org/index.php/ESAPI + * @deprecated since TYPO3 v9.3, will be removed in TYPO3 v10.0 */ class JavaScriptEncoder implements \TYPO3\CMS\Core\SingletonInterface { @@ -51,9 +52,11 @@ class JavaScriptEncoder implements \TYPO3\CMS\Core\SingletonInterface * Populates the $hex map of non-alphanumeric single-byte characters. * * Alphanumerical character are set to NULL in the matrix. + * @deprecated since TYPO3 v9.3, will be removed in TYPO3 v10.0 */ public function __construct() { + trigger_error('TYPO3\'s JavaScriptEncoder will be removed in TYPO3 v10.0, use PHPs native json_encode() or GeneralUtility::quoteJSvalue() instead.', E_USER_DEPRECATED); $this->charsetConversion = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Charset\CharsetConverter::class); for ($i = 0; $i < 256; $i++) { if ($i >= ord('0') && $i <= ord('9') || $i >= ord('A') && $i <= ord('Z') || $i >= ord('a') && $i <= ord('z')) { diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85120-JavaScriptEncoder.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85120-JavaScriptEncoder.rst new file mode 100644 index 0000000000000000000000000000000000000000..ca259efb50425c903a197a2b535ba749ba914054 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85120-JavaScriptEncoder.rst @@ -0,0 +1,35 @@ +.. include:: ../../Includes.txt + +======================================= +Deprecation: #85120 - JavaScriptEncoder +======================================= + +See :issue:`85120` + +Description +=========== + +The standalone utility class :php:`TYPO3\CMS\Core\Encoder\JavaScriptEncoder` has been superseded in TYPO3 6.2 +by PHP's native :php:`json_encode()` and :php:`GeneralUtility::quoteJSvalue()` which provide significantly +performance improvements. The utility class is thus marked for removal in TYPO3 v10.0. + + +Impact +====== + +Instantiating the class will trigger a deprecation message. + + +Affected Installations +====================== + +TYPO3 installations with custom extensions still using this PHP class. + + +Migration +========= + +Use :php:`GeneralUtility::quoteJSvalue()` or :php:`json_encode()` with proper options as second parameter to +escape a string for JavaScript output. + +.. index:: PHP-API, FullyScanned \ No newline at end of file diff --git a/typo3/sysext/core/Tests/Unit/Encoder/JavaScriptEncoderTest.php b/typo3/sysext/core/Tests/UnitDeprecated/Encoder/JavaScriptEncoderTest.php similarity index 97% rename from typo3/sysext/core/Tests/Unit/Encoder/JavaScriptEncoderTest.php rename to typo3/sysext/core/Tests/UnitDeprecated/Encoder/JavaScriptEncoderTest.php index c44b8a2bb689ba4ced8dfa9fd5f84409371e0267..d9d2a36a81b9cf79a99b31607dd2c5c61439bbad 100644 --- a/typo3/sysext/core/Tests/Unit/Encoder/JavaScriptEncoderTest.php +++ b/typo3/sysext/core/Tests/UnitDeprecated/Encoder/JavaScriptEncoderTest.php @@ -1,5 +1,5 @@ <?php -namespace TYPO3\CMS\Core\Tests\Unit\Encoder; +namespace TYPO3\CMS\Core\Tests\UnitDeprecated\Encoder; /* * This file is part of the TYPO3 CMS project. diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php index 691ff43080b793142125d2925bb49d6617429336..68aa6265194a66f7930bcb12b6bc090008e60ddf 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php @@ -679,4 +679,9 @@ return [ 'Deprecation-85102-PhpOptionsUtility.rst', ], ], + 'TYPO3\CMS\Core\Encoding\JavaScriptEncoder' => [ + 'restFiles' => [ + 'Deprecation-85120-JavaScriptEncoder.rst', + ], + ], ];