[BUGFIX] TS: Allow "0" as strPad.padWith 69/25669/2
authorLars Peipmann <lars@peipmann.de>
Sun, 24 Nov 2013 20:36:42 +0000 (21:36 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sun, 24 Nov 2013 20:39:12 +0000 (21:39 +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/25669
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 876bc8a..1a07277 100644 (file)
@@ -2354,7 +2354,7 @@ class ContentObjectRenderer {
                if (!empty($conf['strPad.']['length'])) {
                        $length = intval($conf['strPad.']['length']);
                }
-               if (!empty($conf['strPad.']['padWith'])) {
+               if (isset($conf['strPad.']['padWith']) && strlen($conf['strPad.']['padWith']) > 0) {
                        $padWith = $conf['strPad.']['padWith'];
                }
                if (!empty($conf['strPad.']['type'])) {
index 7957a8e..c1bb82b 100644 (file)
@@ -843,6 +843,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(