Skip to content

Commit 6c951f0

Browse files
Merge branch '7.4' into 8.0
* 7.4: [DependencyInjection][Routing] Fix nested config imports when returning PHP arrays fix compatibility with Relay 0.12.1 [TypeInfo] Fix resolving use statements with line breaks [FrameworkBundle] Fix normalization of enums in workflow transitions Add missing return type for docblock Closure don't use a fixed date fixture when assertions depend on relative times [FrameworkBundle] Fix secrets:encrypt-from-local [Security] Add support for `Sec-Fetch-Site` to `SameOriginCsrfTokenManager` [Console] Optimize mostRecentlyEnteredValue() method [HttpClient] Add QUERY to the list of retriable HTTP methods Update regular expression in URL validator [AssetMapper] Fix parsing @import that don't use url() [Messenger] Add retry delay on amazon sqs [Serializer] CsvEncoder to escape values starting with line feed when escape formulas is enabled
2 parents f1bbc99 + 2434907 commit 6c951f0

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Encoder/CsvEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface
3535

3636
private const UTF8_BOM = "\xEF\xBB\xBF";
3737

38-
private const FORMULAS_START_CHARACTERS = ['=', '-', '+', '@', "\t", "\r"];
38+
private const FORMULAS_START_CHARACTERS = ['=', '-', '+', '@', "\t", "\r", "\n"];
3939

4040
private array $defaultContext = [
4141
self::DELIMITER_KEY => ',',

Tests/Encoder/CsvEncoderTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,15 @@ public function testEncodeFormulas()
308308
$this->encoder->encode(["\ttab"], 'csv')
309309
);
310310

311+
$this->assertSame(<<<'CSV'
312+
0
313+
"'
314+
line feed"
315+
316+
CSV,
317+
$this->encoder->encode(["\nline feed"], 'csv')
318+
);
319+
311320
$this->assertSame(<<<'CSV'
312321
0
313322
"'=1+2"";=1+2"
@@ -436,6 +445,17 @@ public function testEncodeFormulasWithSettingsPassedInContext()
436445
])
437446
);
438447

448+
$this->assertSame(<<<'CSV'
449+
0
450+
"'
451+
line feed"
452+
453+
CSV,
454+
$this->encoder->encode(["\nline feed"], 'csv', [
455+
CsvEncoder::ESCAPE_FORMULAS_KEY => true,
456+
])
457+
);
458+
439459
$this->assertSame(<<<'CSV'
440460
0
441461
"'=1+2"";=1+2"

0 commit comments

Comments
 (0)