Skip to content

Commit d2c9a09

Browse files
committed
Replaced string comparison with substr_compare()
1 parent 12eda44 commit d2c9a09

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Decoder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
namespace s9e\Bencode;
99

1010
use ArrayObject;
11-
use const PHP_INT_MAX, PHP_INT_MIN;
12-
use function is_float, str_contains, strcmp, strlen, strspn, substr;
11+
use const PHP_INT_MAX, PHP_INT_MIN, false;
12+
use function is_float, str_contains, strcmp, strlen, strspn, substr, substr_compare;
1313
use s9e\Bencode\Exceptions\ComplianceError;
1414
use s9e\Bencode\Exceptions\DecodingException;
1515

@@ -198,7 +198,7 @@ protected function decodeDictionary(): ArrayObject
198198
*/
199199
protected function decodeFastString(string $match, int $len, string $value): string
200200
{
201-
if (substr($this->bencoded, $this->offset, $len) === $match)
201+
if (substr_compare($this->bencoded, $match, $this->offset, $len, false) === 0)
202202
{
203203
$this->offset += $len;
204204

0 commit comments

Comments
 (0)