mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Merge pull request #7791 from ohader/issue-7771-4x
Avoid json_encode when serializing non-UTF8 literals
This commit is contained in:
commit
80f972cc38
@ -11,10 +11,10 @@ use function array_unique;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function implode;
|
||||
use function json_encode;
|
||||
use function ksort;
|
||||
use function md5;
|
||||
use function reset;
|
||||
use function serialize;
|
||||
use function sort;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
@ -110,7 +110,7 @@ class Clause
|
||||
sort($possibilities[$i]);
|
||||
}
|
||||
|
||||
$this->hash = md5((string) json_encode($possibilities));
|
||||
$this->hash = md5(serialize($possibilities));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2839,6 +2839,15 @@ class ConditionalTest extends TestCase
|
||||
echo "false";
|
||||
}',
|
||||
],
|
||||
'#7771: non-UTF8 binary data is passed' => [
|
||||
'<?php
|
||||
function matches(string $value): bool {
|
||||
if ("\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" !== $value) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user