[BUGFIX] Detect the conversion to string "0" in stdWrap_csConv 25/48425/8
authorElmar Hinz <t3elmar@gmail.com>
Wed, 1 Jun 2016 06:40:09 +0000 (08:40 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 26 Feb 2017 21:03:22 +0000 (22:03 +0100)
Check for the return value of the converter to be of type string or
return the input. The string "0" is detected.

If the return string of the converter is the empty string, return the
input. This is done to keep the previous behaviour apart from the "0"
issue.

Update the method comment.

Resolves: #76413
Releases: master
Change-Id: I1dc214a6b7cad5815d96c9cdb671862ee99b3063
Reviewed-on: https://review.typo3.org/48425
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index 99f29b5..8e70e39 100644 (file)
@@ -2418,20 +2418,21 @@ class ContentObjectRenderer
     }
 
     /**
-     * csConv
-     * Will convert the current character set of the content to the one given in csConv
+     * stdWrap csConv: Converts the input to UTF-8
      *
-     * @param string $content Input value undergoing processing in this function.
+     * The character set of the input must be specified. Returns the input if
+     * matters go wrong, for example if an invalid character set is given.
+     *
+     * @param string $content The string to convert.
      * @param array $conf stdWrap properties for csConv.
-     * @return string The processed input value
+     * @return string The processed input.
      */
     public function stdWrap_csConv($content = '', $conf = [])
     {
         if (!empty($conf['csConv'])) {
-            /** @var CharsetConverter $charsetConverter */
             $charsetConverter = GeneralUtility::makeInstance(CharsetConverter::class);
             $output = $charsetConverter->conv($content, $charsetConverter->parse_charset($conf['csConv']), 'utf-8');
-            return $output ?: $content;
+            return $output !== false && $output !== '' ? $output : $content;
         } else {
             return $content;
         }