Skip to content

Commit 22dcdfd

Browse files
committed
Do not crash on invalid UTF-8
1 parent bada68a commit 22dcdfd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: src/Parser/ParserException.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use function assert;
88
use function json_encode;
99
use function sprintf;
10+
use const JSON_INVALID_UTF8_SUBSTITUTE;
1011
use const JSON_UNESCAPED_SLASHES;
1112
use const JSON_UNESCAPED_UNICODE;
1213

@@ -84,7 +85,7 @@ public function getExpectedTokenValue(): ?string
8485

8586
private function formatValue(string $value): string
8687
{
87-
$json = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
88+
$json = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_INVALID_UTF8_SUBSTITUTE);
8889
assert($json !== false);
8990

9091
return $json;

0 commit comments

Comments
 (0)