[BUGFIX] TS: Allow "0" as strPad.padWith 36/23536/7
authorLars Peipmann <lars@peipmann.de>
Mon, 2 Sep 2013 13:26:11 +0000 (15:26 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sun, 24 Nov 2013 20:31:22 +0000 (21:31 +0100)
Replaces the test with empty() by isset() and
strlen() > 0. So other strings which are
handled by PHP as empty can be used for padding.

Resolves: #51650
Releases: 6.2, 6.1
Change-Id: Iee62f19f97b958ab2d02c6ca73052810a3c91117
Reviewed-on: https://review.typo3.org/23536
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 89024e3..c0f2ada 100644 (file)
@@ -2492,7 +2492,7 @@ class ContentObjectRenderer {
                        $length = isset($conf['strPad.']['length.']) ? $this->stdWrap($conf['strPad.']['length'], $conf['strPad.']['length.']) : $conf['strPad.']['length'];
                        $length = intval($length);
                }
-               if (!empty($conf['strPad.']['padWith'])) {
+               if (isset($conf['strPad.']['padWith']) && strlen($conf['strPad.']['padWith']) > 0) {
                        $padWith = isset($conf['strPad.']['padWith.']) ? $this->stdWrap($conf['strPad.']['padWith'], $conf['strPad.']['padWith.']) : $conf['strPad.']['padWith'];
                }
                if (!empty($conf['strPad.']['type'])) {
index 8bdd823..d9ccf99 100644 (file)
@@ -858,6 +858,15 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                ),
                                '__Alien___',
                        ),
+                       'pad string with padWith 0 and type both and length 10' => array(
+                               'Alien',
+                               array(
+                                       'length' => '10',
+                                       'padWith' => '0',
+                                       'type' => 'both',
+                               ),
+                               '00Alien000',
+                       ),
                        'pad string with padWith ___ and type both and length 6' => array(
                                'Alien',
                                array(