From eaad700b22adc1acb880fb74d7a78b0da1c19a8c Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Mon, 25 Nov 2024 23:04:52 -0500 Subject: [PATCH 1/2] add useEscapeFormula option to skip CsvEscapeFormula --- modules/backend/behaviors/ImportExportController.php | 6 +++++- modules/backend/models/ExportModel.php | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/backend/behaviors/ImportExportController.php b/modules/backend/behaviors/ImportExportController.php index 057a0758a3..659556ff1c 100644 --- a/modules/backend/behaviors/ImportExportController.php +++ b/modules/backend/behaviors/ImportExportController.php @@ -611,6 +611,7 @@ public function exportFromList($definition = null, $options = []) 'delimiter' => $this->getConfig('defaultFormatOptions[delimiter]', ','), 'enclosure' => $this->getConfig('defaultFormatOptions[enclosure]', '"'), 'escape' => $this->getConfig('defaultFormatOptions[escape]', '\\'), + 'useEscapeFormula' => $this->getConfig('defaultFormatOptions[useEscapeFormula]', True), ]; $options = array_merge($defaultOptions, $options); @@ -625,7 +626,10 @@ public function exportFromList($definition = null, $options = []) $csv->setDelimiter($options['delimiter']); $csv->setEnclosure($options['enclosure']); $csv->setEscape($options['escape']); - $csv->addFormatter(new CsvEscapeFormula()); + + if ($options['useEscapeFormula']) { + $csv->addFormatter(new CsvEscapeFormula()); + } /* * Add headers diff --git a/modules/backend/models/ExportModel.php b/modules/backend/models/ExportModel.php index 7a1b457889..5b7f9b67c9 100644 --- a/modules/backend/models/ExportModel.php +++ b/modules/backend/models/ExportModel.php @@ -84,10 +84,11 @@ protected function processExportData($columns, $results, $options) $defaultOptions = [ 'firstRowTitles' => true, 'useOutput' => false, + 'useEscapeFormula' => true, 'fileName' => 'export.csv', 'delimiter' => null, 'enclosure' => null, - 'escape' => null + 'escape' => null, ]; $options = array_merge($defaultOptions, $options); @@ -112,7 +113,9 @@ protected function processExportData($columns, $results, $options) $csv->setEscape($options['escape']); } - $csv->addFormatter(new CsvEscapeFormula()); + if ($options['useEscapeFormula']) { + $csv->addFormatter(new CsvEscapeFormula()); + } /* * Add headers From 06afeaee5c3ae92ed16f5627fc23f0a4ce5ea952 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Mon, 25 Nov 2024 23:12:41 -0500 Subject: [PATCH 2/2] use lowercase true --- modules/backend/behaviors/ImportExportController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend/behaviors/ImportExportController.php b/modules/backend/behaviors/ImportExportController.php index 659556ff1c..c17d937d48 100644 --- a/modules/backend/behaviors/ImportExportController.php +++ b/modules/backend/behaviors/ImportExportController.php @@ -611,7 +611,7 @@ public function exportFromList($definition = null, $options = []) 'delimiter' => $this->getConfig('defaultFormatOptions[delimiter]', ','), 'enclosure' => $this->getConfig('defaultFormatOptions[enclosure]', '"'), 'escape' => $this->getConfig('defaultFormatOptions[escape]', '\\'), - 'useEscapeFormula' => $this->getConfig('defaultFormatOptions[useEscapeFormula]', True), + 'useEscapeFormula' => $this->getConfig('defaultFormatOptions[useEscapeFormula]', true), ]; $options = array_merge($defaultOptions, $options);