leschweitzer / solrpy

Automatically exported from code.google.com/p/solrpy
0 stars 0 forks source link

Bad URL Encoding #32

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Using solrpy==0.9.5:

There is an issue with URL encoding in this version. For example, I was trying 
to run the following query:

/select?q=stuff&defType=edismax&qf=name+description+name_subwords+description_su
bwords&wt=json&debug=true

c.query(text, fields=['type', 'id', 'name', 'description', 'name_subwords', 
'description_subwords'], defType='edismax', 
qf='name+description+name_subwords+description_subwords')

When core.py tries to URL encode the parameters on this line:

self.conn.request('POST', url, body.encode('UTF-8'), _headers)

the body.encode('UTF-8') changes the '+' characters to their proper URL 
encoding, '%2B'. This is a serious problem because solr doesn't understand qf 
fields delimited by %2B, just +

The Fix:

self.conn.request('POST', url, body.encode('UTF-8').replace('%2B', '+'), 
_headers)

Tada!

Original issue reported on code.google.com by Stevenrecio on 3 Dec 2012 at 9:02