[BUGFIX] CSV rendering in CType table not properly done 57/20157/4
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:03:10 +0000 (13:03 +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/20157
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/css_styled_content/Classes/Controller/CssStyledContentController.php

index fea7c9b..09db33e 100644 (file)
@@ -148,20 +148,16 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                        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))),
+                               $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;';
                                        }