bug: decode_b58b + invalid input
Karel Miko
6 years ago
63 | 63 |
|
64 | 64 |
my $default = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv";
|
65 | 65 |
if (defined $alphabet) {
|
66 | |
return undef if $alphabet !~ /^[a-zA-Z0-9]{58}$/;
|
|
66 |
return undef if $alphabet !~ /^[a-zA-Z0-9]{58}$/ || $base58 !~ /^[$alphabet]+$/;
|
67 | 67 |
eval "\$base58 =~ tr/$alphabet/$default/"; # HACK: https://stackoverflow.com/questions/11415045/using-a-char-variable-in-tr
|
68 | 68 |
return undef if $@;
|
69 | 69 |
}
|
0 | 0 |
use strict;
|
1 | 1 |
use warnings;
|
2 | |
use Test::More tests => 679;
|
|
2 |
use Test::More tests => 680;
|
3 | 3 |
|
4 | 4 |
use Crypt::Misc qw( encode_b64 decode_b64
|
5 | 5 |
encode_b64u decode_b64u
|
|
142 | 142 |
is(unpack("H*", decode_b32z(encode_b32z($b))), $h);
|
143 | 143 |
is(unpack("H*", decode_b32c(encode_b32c($b))), $h);
|
144 | 144 |
}
|
|
145 |
|
|
146 |
is(decode_b58b("111OIl0"), undef, "bug: decode_b58b + invalid input");
|