Closed (fixed)
Project:
Apache Solr Search
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Jul 2009 at 15:47 UTC
Updated:
12 May 2010 at 20:50 UTC
At the beginning of Solr_Base_Query::filter_extract() there are three lines like:
$patterns[] = '/(^| |-)'. $name .':([\[\{](\S+) TO (\S+)[\]\}])/';
Now, while this normally works, it completely breaks if someone would have the crazy idea to use complete URIs as field names. So to preserve peace and prepare for that day, may it never come, I propose the attached patch, which seems to work fine.
| Comment | File | Size | Author |
|---|---|---|---|
| query_class_regex_quote.patch | 1.2 KB | drunken monkey |
Comments
Comment #1
pwolanin commentedI'm pretty sure things will break badly if your field names are not valid PHP identifiers - have you checked that it's even possible to observe this problem?
Comment #2
drunken monkeyWhy should they need to be? I don't see a reason, and it also doesn't seem to be the case.
Anyways, yes, I observed the problem, and it should be pretty easy to reproduce: Just download the unstable2 version of my apachesolr_rdf module and follow the instructions at #527630-1: First prototype done, but omitting this patch.
When trying to search, you'll inevitably get errors from these exact preg_match_all calls, that will instantly vanish once you apply the patch in this issue.
Comment #3
pwolanin commentedbecause every field is used as a property on the document object
Comment #4
drunken monkeyI think that running this proves that you can use anything you want as an indirect variable name. ;) The same goes for object properties.
Comment #5
jpmckinney commentedCrazy stuff.
I'm not sure what characters are allowed in a Solr field name. In any case, it is possible for a custom module to add field aliases that use special characters, in which case we would want to quote those characters when extracting filters. So I see nothing wrong with a one line patch.
Committed to 2.x http://drupal.org/cvs?commit=359680
Comment #6
jpmckinney commentedFixed in 6-1 and 5-2.
http://drupal.org/cvs?commit=360688
http://drupal.org/cvs?commit=360686