-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11092 from weirdan/fix-invalid-utf8-output-in-jso…
…n-reports Fix JSON formatter crashes with invalid UTF in error messages
- Loading branch information
Showing
2 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Psalm\Tests\Internal; | ||
|
||
use Psalm\Internal\Json\Json; | ||
use Psalm\Tests\TestCase; | ||
|
||
final class JsonTest extends TestCase | ||
{ | ||
public function testConvertsInvalidUtf(): void | ||
{ | ||
$invalidUtf = "\xd1"; // incomplete sequence like "ы"[0] | ||
$this->assertEquals('{"data":"<Invalid UTF-8: 0xd1>"}', Json::encode(["data" => $invalidUtf])); | ||
} | ||
} |