[BUGFIX] Correctly handle whitespace in format.date VH 00/45200/2
authorMarkus Klein <markus.klein@typo3.org>
Thu, 10 Dec 2015 14:23:24 +0000 (15:23 +0100)
committerFrans Saris <franssaris@gmail.com>
Fri, 11 Dec 2015 07:37:43 +0000 (08:37 +0100)
Child content may contain line breaks or other whitespace.
Trim the content before processing it.

Resolves: #72152
Releases: master
Change-Id: Ibf5d3fb2c5ca74bb045c4278f0852c47e2131eab
Reviewed-on: https://review.typo3.org/45200
Reviewed-by: Felix Rauch <rauch@skaiamail.de>
Tested-by: Felix Rauch <rauch@skaiamail.de>
Reviewed-by: Josef Glatz <josef.glatz@typo3.org>
Tested-by: Josef Glatz <josef.glatz@typo3.org>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
typo3/sysext/fluid/Classes/ViewHelpers/Format/DateViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/DateViewHelperTest.php

index f0fec84..fb6adf0 100644 (file)
@@ -124,6 +124,9 @@ class DateViewHelper extends AbstractViewHelper implements CompilableInterface
         $date = $arguments['date'];
         $format = $arguments['format'];
         $base = $arguments['base'] === null ? time() : $arguments['base'];
+        if (is_string($base)) {
+            $base = trim($base);
+        }
 
         if ($format === '') {
             $format = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] ?: 'Y-m-d';
@@ -136,6 +139,10 @@ class DateViewHelper extends AbstractViewHelper implements CompilableInterface
             }
         }
 
+        if (is_string($date)) {
+            $date = trim($date);
+        }
+
         if ($date === '') {
             $date = 'now';
         }
index 694a38a..758ed48 100644 (file)
@@ -164,7 +164,7 @@ class DateViewHelperTest extends UnitTestCase
      */
     public function viewHelperUsesChildNodesWithTimestamp()
     {
-        $this->subject->expects($this->once())->method('renderChildren')->will($this->returnValue('1359891658'));
+        $this->subject->expects($this->once())->method('renderChildren')->will($this->returnValue('1359891658' . LF));
         $actualResult = $this->subject->render();
         $this->assertEquals('2013-02-03', $actualResult);
     }