1
0
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:
orklah 2022-03-16 19:00:49 +01:00 committed by GitHub
commit 80f972cc38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -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));
}
}

View File

@ -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;
}'
],
];
}