ap / bencode Goto Github PK
View Code? Open in Web Editor NEWBitTorrent serialisation format
Home Page: https://metacpan.org/release/Bencode
BitTorrent serialisation format
Home Page: https://metacpan.org/release/Bencode
The link http://www.bittorrent.org/protocol.html is broken: 404.
The base bencoding format specifies encoding only for strings of bytes, not Unicode strings. When decoding, there is no way to distinguish if the original data was an UTF-8 string or a byte buffer that appears to look like an UTF-8 string.
The module documentation should clearly specify (and the implementation be tested) how Perl strings with the utf8 flag given in the input to bencode
will be handled. Throwing an exception would be an appropriate behavior, in order to force the user of the module to properly encode its data as bytes.
The bdecode
function should clearly disallow a string of characters and allow only a string of bytes.
When passing a Perl structure containing 'undef' values to the 'bencode' subroutine like so:
use Bencode qw/bencode bdecode/;
use Data::Dumper;
my $x = [1,2,undef,4];
my $b = bencode($x);
warn $b;
my $c = bdecode($b);
warn Dumper($c);
warnings are generated and the result appears to be invalid Bencode.
Use of uninitialized value $data in pattern match (m//) at /home/mark/src/bif/.direnv/perl5/lib/perl5/Bencode.pm line 120.
Use of uninitialized value $data in concatenation (.) or string at /home/mark/src/bif/.direnv/perl5/lib/perl5/Bencode.pm line 121.
Use of uninitialized value $data in concatenation (.) or string at /home/mark/src/bif/.direnv/perl5/lib/perl5/Bencode.pm line 121.
li1ei2e:i4ee at x.pl line 11.
garbage at 7 at x.pl line 13.
I am aware that the original format doesn't cover undefined values, so you probably don't want to support round-tripping of 'undef'. But I would suggest either croaking or encoding a zero-length string in place of the undef (configurable by an option?) to be better than invalid output.
As per subject. Sample fail report: http://www.cpantesters.org/cpan/report/87505520
Cap 1.25 introduced the dot at the end of the message. So either Carp 1.25 is a requirement or the test needs to be rewritten as a like().
Best,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.