We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5fa9740 commit 2e809a7Copy full SHA for 2e809a7
src/Decoder.php
@@ -266,19 +266,14 @@ protected function digitException(): DecodingException
266
*/
267
protected function getSafeBoundary(): int
268
{
269
- $boundary = $this->len - 1;
270
- do
+ if (str_ends_with($this->bencoded, 'e'))
271
272
- $c = substr($this->bencoded, $boundary, 1);
+ return $this->len - 1;
273
}
274
- while (str_contains('0123456789', $c) && --$boundary >= 0);
275
276
- return match ($c)
277
- {
278
- '-' => $boundary - 2,
279
- 'i' => $boundary - 1,
280
- default => $boundary
281
- };
+ preg_match('(i?-?[0-9]*+$)D', $this->bencoded, $m);
+
+ return $this->len - 1 - strlen($m[0] ?? '');
282
283
284
protected function readDigits(string $terminator): string
0 commit comments