diff --git a/src/Plugins/Export/ExportCsv.php b/src/Plugins/Export/ExportCsv.php index f572714839..978345e897 100644 --- a/src/Plugins/Export/ExportCsv.php +++ b/src/Plugins/Export/ExportCsv.php @@ -22,8 +22,9 @@ use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use function __; use function implode; use function is_string; -use function mb_strtolower; +use function str_contains; use function str_replace; +use function strtolower; /** * Handles the export for the CSV format @@ -112,7 +113,7 @@ class ExportCsv extends ExportPlugin public function exportHeader(): bool { // Here we just prepare some values for export - if ($this->terminated === '' || mb_strtolower($this->terminated) === 'auto') { + if ($this->terminated === '' || strtolower($this->terminated) === 'auto') { $this->terminated = "\n"; } else { $this->terminated = str_replace( @@ -193,7 +194,13 @@ class ExportCsv extends ExportPlugin foreach ($result->getFieldNames() as $colAs) { $colAs = $this->getColumnAlias($aliases, $db, $table, $colAs); - if ($this->enclosed === '') { + if ( + $this->enclosed === '' + || (! str_contains($colAs, $this->separator) + && ! str_contains($colAs, $this->enclosed) + && ! str_contains($colAs, $this->terminated) + ) + ) { $insertFields[] = $colAs; } else { $insertFields[] = $this->enclosed @@ -224,7 +231,13 @@ class ExportCsv extends ExportPlugin ); } - if ($this->enclosed === '') { + if ( + $this->enclosed === '' + || (! str_contains($field, $this->separator) + && ! str_contains($field, $this->enclosed) + && ! str_contains($field, $this->terminated) + ) + ) { $insertValues[] = $field; } elseif ($this->escaped !== $this->enclosed) { // also double the escape string if found in the data