From 6c6294fffb4c44b86a87f81ae72f21beecc6b4de Mon Sep 17 00:00:00 2001
From: Elmar Hinz <t3elmar@gmail.com>
Date: Wed, 1 Jun 2016 08:40:09 +0200
Subject: [PATCH] [BUGFIX] Detect the conversion to string "0" in
 stdWrap_csConv

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>
---
 .../Classes/ContentObject/ContentObjectRenderer.php | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
index 99f29b5ee1fe..8e70e39a5c64 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
@@ -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;
         }
-- 
GitLab