Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Business-MaxMind CPAN distribution.

Report information
The Basics
Id: 49346
Status: resolved
Priority: 0/
Queue: Business-MaxMind

People
Owner: Nobody in particular
Requestors: mschout [...] gkg.net
Cc:
AdminCc:

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



Subject: Business::Maxmind chokes if any UTF-8 chars are present in the data.
Date: Tue, 01 Sep 2009 16:40:04 -0500
To: tjmather [...] maxmind.com, bug-Business-MaxMind [...] rt.cpan.org
From: Michael Schout <mschout [...] gkg.net>
Hi! I've discovered a problem with Business::MaxMind::CreditCardFraudDetection and UTF-8 data: If any of the fields passed to CreditCardFraudDetection contain chars above ASCII value 255, the query blows up with error like the following: Can't escape \x{015B}, try uri_escape_utf8() instead at /home/mschout/dev/maxmind/blib/lib/Business/MaxMind/HTTPBase.pm line 156 Attached is a patch against 1.50 that fixes this in the manner suggested by the error message. In addition, I have included a test case (t/utf8.t), and also I added URI 1.36 to PREREQ_PM, because that is when uri_escape_utf8() was first exported by default by URI. If you have any questions, let me know. Thanks. Michael Schout
diff --git a/Makefile.PL b/Makefile.PL index e92242d..21b46e3 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -5,7 +5,10 @@ use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'Business::MaxMind', 'VERSION_FROM' => 'lib/Business/MaxMind/HTTPBase.pm', # finds $VERSION - 'PREREQ_PM' => { LWP::UserAgent => 0 }, # e.g., Module::Name => 1.1 + 'PREREQ_PM' => { + LWP::UserAgent => 0, + URI => 1.36 + }, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT => 'Business::MaxMind - Access MaxMind minFraud, Telephone and Location verification services', # retrieve abstract from module AUTHOR => 'TJ Mather <tjmather@maxmind.com>') : ()), diff --git a/lib/Business/MaxMind/HTTPBase.pm b/lib/Business/MaxMind/HTTPBase.pm index 5f797e6..e01b96b 100644 --- a/lib/Business/MaxMind/HTTPBase.pm +++ b/lib/Business/MaxMind/HTTPBase.pm @@ -153,7 +153,7 @@ sub querySingleServer { $self->{url}; my $check_field = $self->{check_field}; my $queries = $self->{queries}; - my $query_string = join('&', map { "$_=" . uri_escape($queries->{$_}) } keys %$queries); + my $query_string = join('&', map { "$_=" . uri_escape_utf8($queries->{$_}) } keys %$queries); $query_string .= "&clientAPI=$API_VERSION"; if ($self->{"timeout"} > 0) { $self->{ua}->timeout($self->{"timeout"}); diff --git a/t/utf8.t b/t/utf8.t new file mode 100644 index 0000000..abfcf27 --- /dev/null +++ b/t/utf8.t @@ -0,0 +1,31 @@ +#!/usr/bin/env perl + +use strict; +use utf8; +use Test::More tests => 3; +use Test::Exception; + +use_ok 'Business::MaxMind::CreditCardFraudDetection'; + +my $ccfs = Business::MaxMind::CreditCardFraudDetection->new( + isSecure => 1, debug => 1); + +isa_ok $ccfs, 'Business::MaxMind::CreditCardFraudDetection'; + +$ccfs->input( + i => '24.24.24.24', + domain => 'yahoo.com', + city => 'Oświęcim', + region => 'Małopolskie', + postal => '32-600', + country => 'PL', + bin => '549099'); + +eval { + $ccfs->query; + pass("query with UTF-8"); +}; +if ($@) { + fail("query with UTF-8"); + diag($@); +}
Oops, the "use Test::Exception" line is NOT needed in t/utf8.t sorry about that.
CC: Michael Schout <mschout [...] gkg.net>
Subject: Re: [rt.cpan.org #49346] Business::Maxmind chokes if any UTF-8 chars are present in the data.
Date: Wed, 2 Sep 2009 15:11:19 +0200
To: bug-Business-MaxMind [...] rt.cpan.org
From: Boris Zentner <bzentner [...] maxmind.com>
Hi Michael, thanks for the patch. I update Business::Maxmind today. However, using uri_escape_utf8 for all strings encode even latin1 strings as utf8. So that perl < 5.8 send different strings than newer perl versions. Since chars 128..255 have a different encoding. The current solution is to use latin1 whenever possible and 'fallback' to utf8, when octets > 255 get used in the string. Have a nice day! -- Boris Am 01.09.2009 um 23:40 schrieb mschout@gkg.net via RT: Show quoted text
> Tue Sep 01 17:40:42 2009: Request 49346 was acted upon. > Transaction: Ticket created by mschout@gkg.net > Queue: Business-MaxMind > Subject: Business::Maxmind chokes if any UTF-8 chars are present > in the data. > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: mschout@gkg.net > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=49346 > > > > Hi! > > I've discovered a problem with > Business::MaxMind::CreditCardFraudDetection and UTF-8 data: > > If any of the fields passed to CreditCardFraudDetection contain chars > above ASCII value 255, the query blows up with error like the > following: > > Can't escape \x{015B}, try uri_escape_utf8() instead at > /home/mschout/dev/maxmind/blib/lib/Business/MaxMind/HTTPBase.pm line > 156 > > Attached is a patch against 1.50 that fixes this in the manner > suggested > by the error message. In addition, I have included a test case > (t/utf8.t), and also I added URI 1.36 to PREREQ_PM, because that is > when > uri_escape_utf8() was first exported by default by URI. > > If you have any questions, let me know. > > Thanks. > Michael Schout > > diff --git a/Makefile.PL b/Makefile.PL > index e92242d..21b46e3 100644 > --- a/Makefile.PL > +++ b/Makefile.PL > @@ -5,7 +5,10 @@ use ExtUtils::MakeMaker; > WriteMakefile( > 'NAME' => 'Business::MaxMind', > 'VERSION_FROM' => 'lib/Business/MaxMind/HTTPBase.pm', # finds > $VERSION > - 'PREREQ_PM' => { LWP::UserAgent => 0 }, # e.g., Module::Name > => 1.1 > + 'PREREQ_PM' => { > + LWP::UserAgent => 0, > + URI => 1.36 > + }, # e.g., Module::Name => 1.1 > ($] >= 5.005 ? ## Add these new keywords supported since 5.005 > (ABSTRACT => 'Business::MaxMind - Access MaxMind minFraud, > Telephone and Location verification services', # retrieve abstract > from module > AUTHOR => 'TJ Mather <tjmather@maxmind.com>') : ()), > diff --git a/lib/Business/MaxMind/HTTPBase.pm b/lib/Business/MaxMind/ > HTTPBase.pm > index 5f797e6..e01b96b 100644 > --- a/lib/Business/MaxMind/HTTPBase.pm > +++ b/lib/Business/MaxMind/HTTPBase.pm > @@ -153,7 +153,7 @@ sub querySingleServer { > $self->{url}; > my $check_field = $self->{check_field}; > my $queries = $self->{queries}; > - my $query_string = join('&', map { "$_=" . uri_escape($queries-> > {$_}) } keys %$queries); > + my $query_string = join('&', map { "$_=" . uri_escape_utf8 > ($queries->{$_}) } keys %$queries); > $query_string .= "&clientAPI=$API_VERSION"; > if ($self->{"timeout"} > 0) { > $self->{ua}->timeout($self->{"timeout"}); > diff --git a/t/utf8.t b/t/utf8.t > new file mode 100644 > index 0000000..abfcf27 > --- /dev/null > +++ b/t/utf8.t > @@ -0,0 +1,31 @@ > +#!/usr/bin/env perl > + > +use strict; > +use utf8; > +use Test::More tests => 3; > +use Test::Exception; > + > +use_ok 'Business::MaxMind::CreditCardFraudDetection'; > + > +my $ccfs = Business::MaxMind::CreditCardFraudDetection->new( > + isSecure => 1, debug => 1); > + > +isa_ok $ccfs, 'Business::MaxMind::CreditCardFraudDetection'; > + > +$ccfs->input( > + i => '24.24.24.24', > + domain => 'yahoo.com', > + city => 'Oświęcim', > + region => 'Małopolskie', > + postal => '32-600', > + country => 'PL', > + bin => '549099'); > + > +eval { > + $ccfs->query; > + pass("query with UTF-8"); > +}; > +if ($@) { > + fail("query with UTF-8"); > + diag($@); > +}
-- Boris
Fixed in 1.51. Thanks! -- Boris