Skip to content

Commit e65943c

Browse files
committed
fix(output): normalize JSONEachRow line endings
1 parent 8ee28f5 commit e65943c

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/Output/JsonEachRow.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use function explode;
1313
use function implode;
1414
use function json_decode;
15+
use function rtrim;
1516
use function strpos;
1617
use function substr;
1718

@@ -49,6 +50,8 @@ private static function decodeLines(iterable $lines): Generator
4950
$streamedExceptionLines = [];
5051

5152
foreach ($lines as $line) {
53+
$line = rtrim($line, "\r");
54+
5255
if ($streamedExceptionLines !== []) {
5356
$streamedExceptionLines[] = $line;
5457

tests/Output/JsonEachRowTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use function iterator_to_array;
1717
use function str_repeat;
18+
use function str_replace;
1819

1920
#[CoversClass(JsonEachRow::class)]
2021
final class JsonEachRowTest extends TestCaseBase
@@ -94,5 +95,7 @@ public static function provideStreamedExceptionContents(): iterable
9495

9596
yield 'string' => [$contents];
9697
yield 'stream' => [Utils::streamFor($contents)];
98+
yield 'CRLF string' => [str_replace("\n", "\r\n", $contents)];
99+
yield 'CRLF stream' => [Utils::streamFor(str_replace("\n", "\r\n", $contents))];
97100
}
98101
}

0 commit comments

Comments
 (0)