Bug in regexp in function fixViewArgs : can not query with value like IP addresses #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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