[BUGFIX] Avoid applying zero prefix for zero in StaticRangeMapper 20/62920/2
authorOliver Hader <oliver@typo3.org>
Wed, 15 Jan 2020 20:15:25 +0000 (21:15 +0100)
committerSusanne Moog <look@susi.dev>
Thu, 16 Jan 2020 09:59:47 +0000 (10:59 +0100)
Range from '01' to '03' correctly leads to ['01','02','03']. The
prefix mechanism is however applied for a range from '0' to '11'.
This should only happen when explicitly having used '00' to '11'.

Resolves: #90123
Releases: master, 9.5
Change-Id: I90672c4d94cb97d61fe45f8d6e1382b8be3b49b7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62920
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Susanne Moog <look@susi.dev>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Tobi Kretschmann <tobi@tobishome.de>
Reviewed-by: Felix P. <f.pachowsky@neusta.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Susanne Moog <look@susi.dev>
typo3/sysext/core/Classes/Routing/Aspect/StaticRangeMapper.php
typo3/sysext/extbase/Tests/Unit/Routing/Aspect/StaticRangeMapperTest.php

index b70536d..bb83251 100644 (file)
@@ -153,6 +153,7 @@ class StaticRangeMapper implements StaticMappableAspectInterface, \Countable
     {
         if (!preg_match('#^\d+$#', $this->start)
             || !preg_match('#^\d+$#', $this->end)
+            || $this->start === '0' || $this->end === '0'
             || $this->start[0] !== '0' && $this->end[0] !== '0'
         ) {
             return $range;
index 9a6bc97..9d90317 100644 (file)
@@ -16,13 +16,13 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Routing\Aspect;
  * The TYPO3 project - inspiring people to share!
  */
 
+use PHPUnit\Framework\TestCase;
 use TYPO3\CMS\Core\Routing\Aspect\StaticRangeMapper;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class StaticRangeMapperTest extends UnitTestCase
+class StaticRangeMapperTest extends TestCase
 {
     public function valueSettingsDataProvider(): array
     {
@@ -65,6 +65,19 @@ class StaticRangeMapperTest extends UnitTestCase
                     'D' => null,
                 ]
             ],
+            '0-11 (no zero prefix)' => [
+                '0',
+                '11',
+                [
+                    '00' => null,
+                    '01' => null,
+                    '0' => '0',
+                    '1' => '1',
+                    '10' => '10',
+                    '11' => '11',
+                    '12' => null,
+                ]
+            ],
             '2-11 (no zero prefix)' => [
                 '2',
                 '11',
@@ -82,6 +95,17 @@ class StaticRangeMapperTest extends UnitTestCase
                     '12' => null,
                 ]
             ],
+            '00-11 (no zero prefix)' => [
+                '00',
+                '11',
+                [
+                    '00' => '00',
+                    '01' => '01',
+                    '10' => '10',
+                    '11' => '11',
+                    '12' => null,
+                ]
+            ],
             '02-11 (apply zero prefix)' => [
                 '02',
                 '11',