Skip Menu |

This queue is for tickets about the Encode-Base32-Crockford CPAN distribution.

Report information
The Basics
Id: 35385
Status: resolved
Priority: 0/
Queue: Encode-Base32-Crockford

People
Owner: Nobody in particular
Requestors: dgl@dgl.cx (no email address)
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.12
Fixed in: (no value)



Subject: Encoding fails for some values
The inverse symbol table wasn't consulted for the final value, this meant actual numbers rather than base32 characters were appended. Patch attached.
Subject: encode-base32.patch
diff -Nru Encode-Base32-Crockford-1.12/lib/Encode/Base32/Crockford.pm Encode-Base32-Crockford-1.12-dgl/lib/Encode/Base32/Crockford.pm --- Encode-Base32-Crockford-1.12/lib/Encode/Base32/Crockford.pm 2008-04-10 12:39:47.000000000 +0100 +++ Encode-Base32-Crockford-1.12-dgl/lib/Encode/Base32/Crockford.pm 2008-04-24 22:41:09.000000000 +0100 @@ -76,8 +76,13 @@ redo DIGITS; } else { - push @digits, $number; - return join '', reverse @digits; + if ($number > 9) { + push @digits, $SYMBOLS_INVERSE{$number}; + } else { + push @digits, $number; + } + + return join '', reverse @digits; } } } diff -Nru Encode-Base32-Crockford-1.12/MANIFEST Encode-Base32-Crockford-1.12-dgl/MANIFEST --- Encode-Base32-Crockford-1.12/MANIFEST 2008-04-10 12:39:47.000000000 +0100 +++ Encode-Base32-Crockford-1.12-dgl/MANIFEST 2008-04-24 22:47:37.000000000 +0100 @@ -4,6 +4,8 @@ README lib/Encode/Base32/Crockford.pm t/base32.t +t/encode_decode.t +t/encode_decode_checksum.t t/pod.t t/pod_coverage.t Makefile.PL diff -Nru Encode-Base32-Crockford-1.12/t/base32.t Encode-Base32-Crockford-1.12-dgl/t/base32.t --- Encode-Base32-Crockford-1.12/t/base32.t 2008-04-10 12:39:47.000000000 +0100 +++ Encode-Base32-Crockford-1.12-dgl/t/base32.t 2008-04-24 22:42:54.000000000 +0100 @@ -75,7 +75,7 @@ is(base32_encode(128), 40, "encode()"); -is(base32_encode(500), '15M', "encode larger number"); +is(base32_encode(500), 'FM', "encode larger number"); is(base32_encode_with_checksum(128), '40H', "encode_with_checksum()"); is(base32_encode_with_checksum(9), '99', "checksum encode small number"); diff -Nru Encode-Base32-Crockford-1.12/t/encode_decode_checksum.t Encode-Base32-Crockford-1.12-dgl/t/encode_decode_checksum.t --- Encode-Base32-Crockford-1.12/t/encode_decode_checksum.t 1970-01-01 01:00:00.000000000 +0100 +++ Encode-Base32-Crockford-1.12-dgl/t/encode_decode_checksum.t 2008-04-24 22:41:54.000000000 +0100 @@ -0,0 +1,13 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +use constant MAX => 1024; +use Test::More tests => MAX + 1; + +use Encode::Base32::Crockford qw(:all); + +for my $num(0 .. MAX) { + is(base32_decode_with_checksum(base32_encode_with_checksum($num)), $num, "check encode, decode $num"); +} diff -Nru Encode-Base32-Crockford-1.12/t/encode_decode.t Encode-Base32-Crockford-1.12-dgl/t/encode_decode.t --- Encode-Base32-Crockford-1.12/t/encode_decode.t 1970-01-01 01:00:00.000000000 +0100 +++ Encode-Base32-Crockford-1.12-dgl/t/encode_decode.t 2008-04-24 22:41:59.000000000 +0100 @@ -0,0 +1,13 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +use constant MAX => 1024; +use Test::More tests => MAX + 1; + +use Encode::Base32::Crockford qw(:all); + +for my $num(0 .. MAX) { + is(base32_decode(base32_encode($num)), $num, "check encode, decode $num"); +}
Subject: Re: [rt.cpan.org #35385] Encoding fails for some values
Date: Fri, 25 Apr 2008 07:12:46 +0100
To: bug-Encode-Base32-Crockford [...] rt.cpan.org
From: "Earle Martin" <earle [...] downlode.org>
2008/4/24 David Leadbeater via RT <bug-Encode-Base32-Crockford@rt.cpan.org>: Show quoted text
> Patch attached.
What a stellar patch (and what a bug). Thank you very much, a new version is on its way to CPAN right now. Best wishes, Earle. -- Earle Martin http://downlode.org/