Skip Menu |

This queue is for tickets about the GD-Barcode-Code93 CPAN distribution.

Report information
The Basics
Id: 39372
Status: resolved
Priority: 0/
Queue: GD-Barcode-Code93

People
Owner: DIMARTINO [...] cpan.org
Requestors: perl [...] joelrichard.com
Cc:
AdminCc:

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



Subject: Incorrect check characters for Barcode93
I found the following happening while generating the barcode for the value "494-5006". In the calculateSums function, the checksum digits are calculated correctly in a reverse order and are placed into the arrray: 'I', '(+)', '9', '0', '0', '5', '-', '4', '9', '4' The error arises when the array is reversed and then --converted to a string--. This is incorrect. After adding the *'s around the string, you end up with a string of: *494-5009)+(I* You can see that this is a problem. Instead of using (+), it ends up using only "+" (not "(+)" and that is the wrong character. This -must- converted to it's binary representation as an array. The update for the barcode() function is as follows. I have tested that this works. sub barcode { my $self = shift; my @sum_text = ('*', $self->calculateSums, '*'); my $return_string = ''; map { $return_string .= $code93bar->{$_} } @sum_text; return $return_string . "1"; } Additonally, the use of "*" as the start and stop character is partially legitimate, but given that code 93 can -technically- encode any ASCII character, that would need to be changed if Code 93 were to be used outside of it's normal set of 47 characters, but since this module only supports the basic 47 chars, that's a moot point. :) Hopefully this will get into the main distribution. Not that it changes anything, but I'm using perl 5.8.4 running under debian linux (sarge and etch) on a 2.6 kernel. --Joel
From: perl [...] joelrichard.com
Small followup, I was encoding the value "494-5009", which I use in my example, but this error affects both values. On Wed Sep 17 22:23:28 2008, cajunjoel wrote: Show quoted text
> I found the following happening while generating the barcode for the > value "494-5006". > > In the calculateSums function, the checksum digits are calculated > correctly in a reverse order and are placed into the arrray: > > 'I', '(+)', '9', '0', '0', '5', '-', '4', '9', '4' > > The error arises when the array is reversed and then --converted to a > string--. This is incorrect. After adding the *'s around the string, you > end up with a string of: > > *494-5009)+(I* > > You can see that this is a problem. Instead of using (+), it ends up > using only "+" (not "(+)" and that is the wrong character. > > This -must- converted to it's binary representation as an array. The > update for the barcode() function is as follows. I have tested that this > works. > > sub barcode { > my $self = shift; > > my @sum_text = ('*', $self->calculateSums, '*'); > > my $return_string = ''; > map { $return_string .= $code93bar->{$_} } @sum_text; > return $return_string . "1"; > } > > Additonally, the use of "*" as the start and stop character is partially > legitimate, but given that code 93 can -technically- encode any ASCII > character, that would need to be changed if Code 93 were to be used > outside of it's normal set of 47 characters, but since this module only > supports the basic 47 chars, that's a moot point. :) > > Hopefully this will get into the main distribution. > > Not that it changes anything, but I'm using perl 5.8.4 running under > debian linux (sarge and etch) on a 2.6 kernel. > > --Joel
I have applied your patch and release the module as part of version 1.3.1. Thanks so much for the fix.