Subject: | bencode bug |
Date: | Tue, 25 Oct 2016 12:40:21 +0300 |
To: | bug-Convert-Bencode [...] rt.cpan.org |
From: | Vitaly Gimly <vgimly [...] gmail.com> |
Hello.
Just discovered that infohash calculated for certan torrent files missmatch
from calculated for most public available clients and by function
Convert::Bencode::bencode.
The differece is in missing support for negative numbers in module.
for example:
number -1 should be converted to "i-1e", not "2:-1", like module does.
fix is easy: file Bencode.pm, regexp on line 105:
if($item =~ /^\d+$/) {
should be:
if($item =~ /^-?\d+$/) {
Or even better use more complicated regexp from module Bencode by
Αριστοτέλης Παγκαλτζής:
Line 120 of file
http://cpansearch.perl.org/src/ARISTOTLE/Bencode-1.402/lib/Bencode.pm
return sprintf 'i%se', $data if $data =~ m/\A (?: 0 | -? [1-9] \d* ) \z/x;
--
Gimly..