Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/Serializer/Encoder/CsvEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface

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

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

private array $defaultContext = [
self::DELIMITER_KEY => ',',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,15 @@ public function testEncodeFormulas()
$this->encoder->encode(["\ttab"], 'csv')
);

$this->assertSame(<<<'CSV'
0
"'
line feed"

CSV,
$this->encoder->encode(["\nline feed"], 'csv')
);

$this->assertSame(<<<'CSV'
0
"'=1+2"";=1+2"
Expand Down Expand Up @@ -438,6 +447,17 @@ public function testEncodeFormulasWithSettingsPassedInContext()
])
);

$this->assertSame(<<<'CSV'
0
"'
line feed"

CSV,
$this->encoder->encode(["\nline feed"], 'csv', [
CsvEncoder::ESCAPE_FORMULAS_KEY => true,
])
);

$this->assertSame(<<<'CSV'
0
"'=1+2"";=1+2"
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.