[BUGFIX] CSV rendering in CType table not properly done 01/22001/3
authorPatrick Broens <patrick@patrickbroens.nl>
Thu, 25 Apr 2013 13:09:43 +0000 (15:09 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sat, 6 Jul 2013 11:10:43 +0000 (13:10 +0200)
The CSV rendering in CType table is not done properly in
css_styled_content method render_table. It uses explode with the
delimiter, but this character can also be in the cell itself.

This patch uses the PHP function str_getcsv, which is supported from PHP
version 5.3 >

Change-Id: I5707b006ab1143c108473e5ed7079e6e65cdddca
Fixes: #47356
Releases: 6.0, 6.1, 6.2
Reviewed-on: https://review.typo3.org/22001
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/css_styled_content/Classes/Controller/CssStyledContentController.php

index 58c1ade..9ab4753 100644 (file)
@@ -152,17 +152,14 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                        $rows = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $content);
                        reset($rows);
                        // Find number of columns to render:
-                       $cols = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cObj->data['cols'] ? $this->cObj->data['cols'] : count(explode($delimiter, current($rows))), 0, 100);
+               $cols = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cObj->data['cols'] ? $this->cObj->data['cols'] : count(str_getcsv(current($rows), $delimiter, $quotedInput)), 0, 100);
+
                        // Traverse rows (rendering the table here)
                        $rCount = count($rows);
                        foreach ($rows as $k => $v) {
-                               $cells = explode($delimiter, $v);
+                               $cells = str_getcsv($v, $delimiter, $quotedInput);
                                $newCells = array();
                                for ($a = 0; $a < $cols; $a++) {
-                                       // Remove quotes if needed
-                                       if ($quotedInput && substr($cells[$a], 0, 1) == $quotedInput && substr($cells[$a], -1, 1) == $quotedInput) {
-                                               $cells[$a] = substr($cells[$a], 1, -1);
-                                       }
                                        if (!strcmp(trim($cells[$a]), '')) {
                                                $cells[$a] = '&nbsp;';
                                        }
@@ -1186,4 +1183,4 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
        }
 
 }
-?>
\ No newline at end of file
+?>