Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Symfony/Component/Translation/Loader/CsvFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CsvFileLoader extends FileLoader
{
private $delimiter = ';';
private $enclosure = '"';
private $escape = '\\';
private $escape = '';

/**
* {@inheritdoc}
Expand All @@ -38,7 +38,7 @@ protected function loadResource(string $resource)
}

$file->setFlags(\SplFileObject::READ_CSV | \SplFileObject::SKIP_EMPTY);
$file->setCsvControl($this->delimiter, $this->enclosure, $this->escape);
$file->setCsvControl($this->delimiter, $this->enclosure, '' === $this->escape && \PHP_VERSION_ID < 70400 ? '\\' : $this->escape);

foreach ($file as $data) {
if (false === $data) {
Expand All @@ -56,10 +56,10 @@ protected function loadResource(string $resource)
/**
* Sets the delimiter, enclosure, and escape character for CSV.
*/
public function setCsvControl(string $delimiter = ';', string $enclosure = '"', string $escape = '\\')
public function setCsvControl(string $delimiter = ';', string $enclosure = '"', string $escape = '')
{
$this->delimiter = $delimiter;
$this->enclosure = $enclosure;
$this->escape = $escape;
$this->escape = '' === $escape && \PHP_VERSION_ID < 70400 ? '\\' : $escape;
}
}