[BUGFIX] Use PHP native htmlspecialchars_decode() 73/27473/3
authorŁukas Jurys <lukasz.jurys@me.com>
Sat, 8 Feb 2014 18:21:37 +0000 (19:21 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 9 Feb 2014 19:41:38 +0000 (20:41 +0100)
Method Generalutility::htmlspecialchars_decode()
was replaced by htmlspecialchars_decode().
Also  Generalutility::htmlspecialchars_decode()
has been marked as deprecated

Resolves: #54777
Releases: 6.2
Change-Id: Idc9b12d8a1dc2746ee0f742c37c640118c9f69c3
Reviewed-on: https://review.typo3.org/27473
Reviewed-by: Oliver Klee
Reviewed-by: Karol Lamparski
Reviewed-by: Marcin Sągol
Tested-by: Marcin Sągol
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/core/Classes/Database/SoftReferenceIndex.php
typo3/sysext/core/Classes/Html/HtmlParser.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
typo3/sysext/indexed_search/Classes/Hook/CrawlerHook.php
typo3/sysext/indexed_search/Classes/Indexer.php
typo3/sysext/opendocs/Classes/Controller/OpendocsController.php

index 79c11d7..66942e0 100644 (file)
@@ -198,7 +198,7 @@ class SoftReferenceIndex {
                        if ($k % 2) {
                                // Get file reference:
                                $attribs = $htmlParser->get_tag_attributes($v);
-                               $srcRef = GeneralUtility::htmlspecialchars_decode($attribs[0]['src']);
+                               $srcRef = htmlspecialchars_decode($attribs[0]['src']);
                                $pI = pathinfo($srcRef);
                                // If it looks like a local image, continue. Otherwise ignore it.
                                $absPath = GeneralUtility::getFileAbsFileName(PATH_site . $srcRef);
@@ -342,7 +342,7 @@ class SoftReferenceIndex {
                                }
                                // Get file reference:
                                if (isset($attribs[0][$attributeName])) {
-                                       $srcRef = GeneralUtility::htmlspecialchars_decode($attribs[0][$attributeName]);
+                                       $srcRef = htmlspecialchars_decode($attribs[0][$attributeName]);
                                        // Set entry:
                                        $tokenID = $this->makeTokenID($k);
                                        $elements[$k] = array();
index f56234c..c66df9d 100644 (file)
@@ -557,7 +557,7 @@ class HtmlParser {
                                if ($val != '=') {
                                        if ($valuemode) {
                                                if ($name) {
-                                                       $attributes[$name] = $deHSC ? GeneralUtility::htmlspecialchars_decode($val) : $val;
+                                                       $attributes[$name] = $deHSC ? htmlspecialchars_decode($val) : $val;
                                                        $attributesMeta[$name]['dashType'] = $metaC[$key];
                                                        $name = '';
                                                }
@@ -990,7 +990,7 @@ class HtmlParser {
                } elseif ($dir == 2) {
                        $value = GeneralUtility::deHSCentities(htmlspecialchars($value));
                } elseif ($dir == -1) {
-                       $value = GeneralUtility::htmlspecialchars_decode($value);
+                       $value = htmlspecialchars_decode($value);
                }
                return $value;
        }
index 03f40cd..a25882f 100644 (file)
@@ -1012,16 +1012,14 @@ class GeneralUtility {
        /**
         * Inverse version of htmlspecialchars()
         *
+        * @deprecated since 6.2 replaced by php native htmlspecialchars_decode()
+        *
         * @param string $value Value where &gt;, &lt;, &quot; and &amp; should be converted to regular chars.
         * @return string Converted result.
         */
        static public function htmlspecialchars_decode($value) {
-               return str_replace(
-                       array('&gt;', '&lt;', '&quot;', '&amp;'),
-                       array('>', '<', '"', '&'),
-                       $value
-               );
-
+               GeneralUtility::logDeprecatedFunction();
+               return htmlspecialchars_decode($value);
        }
 
        /**
index e6d4759..a195595 100644 (file)
@@ -890,7 +890,7 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        public function htmlspecialcharsDecodeReturnsDecodedString() {
                $string = '<typo3 version="6.0">&nbsp;</typo3>';
                $encoded = htmlspecialchars($string);
-               $decoded = Utility\GeneralUtility::htmlspecialchars_decode($encoded);
+               $decoded = htmlspecialchars_decode($encoded);
                $this->assertEquals($string, $decoded);
        }
 
index e766f69..d41b0ac 100644 (file)
@@ -519,7 +519,7 @@ class CrawlerHook {
                // Traverse links:
                foreach ($list as $count => $linkInfo) {
                        // Decode entities:
-                       $subUrl = GeneralUtility::htmlspecialchars_decode($linkInfo['href']);
+                       $subUrl = htmlspecialchars_decode($linkInfo['href']);
                        $qParts = parse_url($subUrl);
                        if (!$qParts['scheme']) {
                                $relativeUrl = GeneralUtility::resolveBackPath($subUrl);
index 1c0ed19..45e8fec 100644 (file)
@@ -767,9 +767,9 @@ class Indexer {
                        // Decode entities:
                        if ($linkInfo['localPath']) {
                                // localPath means: This file is sent by a download script. While the indexed URL has to point to $linkInfo['href'], the absolute path to the file is specified here!
-                               $linkSource = GeneralUtility::htmlspecialchars_decode($linkInfo['localPath']);
+                               $linkSource = htmlspecialchars_decode($linkInfo['localPath']);
                        } else {
-                               $linkSource = GeneralUtility::htmlspecialchars_decode($linkInfo['href']);
+                               $linkSource = htmlspecialchars_decode($linkInfo['href']);
                        }
                        // Parse URL:
                        $qParts = parse_url($linkSource);
index f611b76..0a4ccf1 100644 (file)
@@ -151,7 +151,7 @@ class OpendocsController implements \TYPO3\CMS\Backend\Toolbar\ToolbarItemHookIn
                        // Record seems to be deleted
                        return '';
                }
-               $label = htmlspecialchars(strip_tags(\TYPO3\CMS\Core\Utility\GeneralUtility::htmlspecialchars_decode($document[0])));
+               $label = htmlspecialchars(strip_tags(htmlspecialchars_decode($document[0])));
                $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $record);
                $link = $GLOBALS['BACK_PATH'] . 'alt_doc.php?' . $document[2];
                $pageId = (int)$document[3]['uid'];