CC: | Alexandre SIMON <Alexandre.Simon [...] ciril.fr> |
Subject: | Bug in regexp in function fixViewArgs : can not query with value like IP addresses |
Date: | Wed, 08 Dec 2010 10:45:06 +0100 |
To: | maverick [...] smurfbane.org, bug-couchdb-client [...] rt.cpan.org |
From: | Alexandre SIMON <Alexandre.Simon [...] ciril.fr> |
Hi all,
We are working on a CouchDB server (1.0.1) with the Perl API
CouchDB::Client (0.09).
When we create documents with a key that is an IP address :
---- CODE
my $ip = "192.168.100.1";
$cdb->newDoc($ip , undef, { user => "foobar"}, undef)->create;
print "argsToQuery=".$cdb->argsToQuery("key" => "$ip")."\n";
my $docs = $cdb->listDocs( "key" => "$ip" );
---- RESULTS
argsToQuery=?key=192.168.100.1
Connection error: 400 Bad Request at
/usr/local/perl-5.8.8/lib/site_perl/5.8.8/CouchDB/Client/DB.pm line 114
CouchDB::Client::DB::listDocIdRevs('CouchDB::Client::DB=HASH(0x939c9a4)', 'key',
192.168.100.1) called at
/usr/local/perl-5.8.8/lib/site_perl/5.8.8/CouchDB/Client/DB.pm line 129
CouchDB::Client::DB::listDocs('CouchDB::Client::DB=HASH(0x939c9a4)',
'key', 192.168.100.1) called at ./bar.pl line 34
and in the couch.log we have something like :
[Wed, 08 Dec 2010 09:35:18 GMT] [error] [<0.9484.6>] attempted upload of
invalid JSON (set log_level to debug to log it)
===> the problem is in the function fixViewArgs that does not correctly
takes care of IP address : the regexp "/^\d+(?:\.\d+)*$/s)" must be more
strict to handle only integers or floats. If we change this regexp with
"/^\d+(?:\.){0,1}\d*$/s" all will be ok for IP addresses.
Now, with this new regexp exp we have :
---- RESULTS
argsToQuery=?key=%22192.168.100.1%22
I have attached the patch to correct this bug.
Dear Maverick, do you confirm the problem ?
I remain available to help you correct this bug.
Best regards,
Alex.
PS: many, many thanks for this module ! .. and keep relax ;-)
--
Alexandre SIMON
Cellule (R)éseau StanNet/Lothaire
C.I.R.I.L. | Perm. réseau : +33 (0)3.83.68.24.24
Château du Montet | Tél. direct : +33 (0)3.83.68.24.32
Rue du Doyen Roubault | Fax : +33 (0)3.83.68.24.01
F - 54500 VANDOEUVRE | Email : Alexandre.Simon@ciril.fr
Message body is not shown because sender requested not to inline it.