Subject: | wrong _max_length in ISBN13.pm |
The '_max_length' method in 'ISBN13.pm' returns the wrong value. It
doesn't show up in the current set of tests, but by adding a few extra
ones it does.
I've attached a patch which corrects this and checks all the values
'isbns.txt' to see if they can be decoded correctly as ISBN-13 values
after adding the '978' prefix and correcting the checksum.
You can also see the problem by adding some values in 'isbn13s.txt'.
Here's are the values I've been using:
9780439994149
9780747591054
9780060533229
9789607771278
9780900083181
They all work even with the wrong max length value, except the last
which is incorrectly identified as being invalid.
Hope that helps.
Subject: | isbn-wrong-length.patch |
diff -ur Business-ISBN-2.02_02.orig/lib/ISBN13.pm Business-ISBN-2.02_02/lib/ISBN13.pm
--- Business-ISBN-2.02_02.orig/lib/ISBN13.pm 2007-08-15 09:04:56.000000000 +0100
+++ Business-ISBN-2.02_02/lib/ISBN13.pm 2007-09-01 09:22:06.000000000 +0100
@@ -26,7 +26,7 @@
($VERSION) = q$Revision: 2.5 $ =~ m/(\d+\.\d+)\s*$/;
-sub _max_length { 10 }
+sub _max_length { 13 }
sub _set_type { $_[0]->{type} = 'ISBN13' }
diff -ur Business-ISBN-2.02_02.orig/t/isbn10.t Business-ISBN-2.02_02/t/isbn10.t
--- Business-ISBN-2.02_02.orig/t/isbn10.t 2007-08-13 04:15:22.000000000 +0100
+++ Business-ISBN-2.02_02/t/isbn10.t 2007-09-01 09:24:22.000000000 +0100
@@ -142,6 +142,10 @@
$bad++ unless $result eq Business::ISBN::GOOD_ISBN;
print STDERR "$_ is not valid? [ $result -> $text ]\n"
unless $result eq Business::ISBN::GOOD_ISBN;
+
+ my $isbn13 = Business::ISBN->new( "978$_" );
+ $isbn13->fix_checksum;
+ $bad++ unless $isbn->is_valid;
}
close FILE;