Skip to content

Commit e104cd2

Browse files
committed
bug #58266 [HttpKernel] pass CSV escape characters explicitly (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [HttpKernel] pass CSV escape characters explicitly | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT Not passing the `$escape` parameter is deprecated since PHP 8.4 as the default value will change in the future. Commits ------- 8c32db3 pass CSV escape characters explicitly
2 parents de845c2 + 8c32db3 commit e104cd2

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function find(?string $ip, ?string $url, ?int $limit, ?string $method, ?i
6060

6161
$result = [];
6262
while (\count($result) < $limit && $line = $this->readLineFromFile($file)) {
63-
$values = str_getcsv($line);
63+
$values = str_getcsv($line, ',', '"', '\\');
6464

6565
if (7 !== \count($values)) {
6666
// skip invalid lines
@@ -187,7 +187,7 @@ public function write(Profile $profile): bool
187187
$profile->getTime(),
188188
$profile->getParentToken(),
189189
$profile->getStatusCode(),
190-
]);
190+
], ',', '"', '\\');
191191
fclose($file);
192192
}
193193

src/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,12 @@ public function testMultiRowIndexFile()
336336

337337
$handle = fopen($this->tmpDir.'/index.csv', 'r');
338338
for ($i = 0; $i < $iteration; ++$i) {
339-
$row = fgetcsv($handle);
339+
$row = fgetcsv($handle, null, ',', '"', '\\');
340340
$this->assertEquals('token'.$i, $row[0]);
341341
$this->assertEquals('127.0.0.'.$i, $row[1]);
342342
$this->assertEquals('http://foo.bar/'.$i, $row[3]);
343343
}
344-
$this->assertFalse(fgetcsv($handle));
344+
$this->assertFalse(fgetcsv($handle, null, ',', '"', '\\'));
345345
}
346346

347347
public function testReadLineFromFile()

src/Symfony/Component/Translation/Dumper/CsvFileDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function formatCatalogue(MessageCatalogue $messages, string $domain, arra
3131
$handle = fopen('php://memory', 'r+');
3232

3333
foreach ($messages->all($domain) as $source => $target) {
34-
fputcsv($handle, [$source, $target], $this->delimiter, $this->enclosure);
34+
fputcsv($handle, [$source, $target], $this->delimiter, $this->enclosure, '\\');
3535
}
3636

3737
rewind($handle);

src/Symfony/Component/Validator/Resources/bin/sync-iban-formats.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private function readPropertiesFromRegistry(array $properties): array
129129
array_shift($lines);
130130

131131
foreach ($lines as $line) {
132-
$columns = str_getcsv($line, "\t");
132+
$columns = str_getcsv($line, "\t", '"', '\\');
133133
$propertyLabel = array_shift($columns);
134134

135135
if (!isset($properties[$propertyLabel])) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy