panjiwa10028 / solr-php-client

Automatically exported from code.google.com/p/solr-php-client
Other
0 stars 0 forks source link

possible issue, preg_replace on Service.php after http_build_query #26

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In using arrays of arrays in parameters, such as facet.field note the
foo[#]=bar

the preg_replace of preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=',
$queryString); 

should be

preg_replace('/\[(?:[0-9]|[1-9][0-9]+)\]=/', '=', $queryString);

as the '[' and ']' are not encoded by http_build_query

Original issue reported on code.google.com by orangele...@gmail.com on 18 Nov 2009 at 5:25

GoogleCodeExporter commented 8 years ago
Can you give me specifics on the version of PHP you're seeing this on.  With my 
version of php I do see the 
brackets encoded (as they should be). I hope this isn't a change in a newer 
version of php.

I'm testing against :

PHP 5.2.4-2ubuntu5.7 with Suhosin-Patch 0.9.6.2 (cli) (built: Aug 21 2009 
22:17:39) 
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

Simple test script:
{{{
<?php

$params = array(
        'facet.field' => array(
                'one',
                'two',
                'three'
        )
);

// will output 
facet.field%5B0%5D=one&facet.field%5B1%5D=two&facet.field%5B2%5D=three
echo http_build_query($params), "\n";
?>
}}}

Original comment by donovan....@gmail.com on 18 Nov 2009 at 5:46

GoogleCodeExporter commented 8 years ago
Ah, a quick look at the php manual page: 
http://us3.php.net/manual/en/function.http-build-query.php

as of version 5.1.3 all square brackets are escaped properly.  So I'm guessing 
you're using a version previous to 
that and the json pecl extension.?

I could put a version check in to use the modified regex for older php versions.

Original comment by donovan....@gmail.com on 18 Nov 2009 at 5:51

GoogleCodeExporter commented 8 years ago
Hi, yes, older php version issue and not code issue - but version check would be
good. cheers.

Original comment by orangele...@gmail.com on 18 Nov 2009 at 6:51

GoogleCodeExporter commented 8 years ago
Fixed in r23

Original comment by donovan....@gmail.com on 21 Nov 2009 at 2:03