Make sure slashes are properly escaped in the search query.
This commit is contained in:
parent
82faa75891
commit
169559ddc8
|
@ -4,6 +4,11 @@ Changelog
|
|||
4.0 - unreleased
|
||||
------------------
|
||||
|
||||
- Make sure slashes are properly escaped in the search query. Solr 4.0 added
|
||||
regular expression support, which means that '/' is now a special character
|
||||
and must be escaped if searching for literal forward slash.
|
||||
[timo]
|
||||
|
||||
- Implement the getDataOrigin method for the FlareContentListingObject that
|
||||
plone.app.contentlisting defines and that plone.app.search expects to exist.
|
||||
[timo]
|
||||
|
|
|
@ -95,7 +95,12 @@ class Search(object):
|
|||
elif not value: # solr doesn't like empty fields (+foo:"")
|
||||
if not name:
|
||||
continue
|
||||
logger.info('empty search term form "%s:%s", aborting buildQuery' % (name,value))
|
||||
logger.info(
|
||||
'empty search term form "%s:%s", aborting buildQuery' % (
|
||||
name,
|
||||
value
|
||||
)
|
||||
)
|
||||
return {}
|
||||
elif field.class_ == 'solr.BoolField':
|
||||
if not isinstance(value, (tuple, list)):
|
||||
|
@ -135,6 +140,11 @@ class Search(object):
|
|||
value = '"%s"' % value
|
||||
else:
|
||||
value = quote(value)
|
||||
# Solr 4.0 added regular expression support, which means
|
||||
# that '/' is now a special character and must be escaped
|
||||
# if searching for literal forward slash.
|
||||
if '/' in value:
|
||||
value = value.replace('/', '\/')
|
||||
if not value: # don't search for empty strings, even quoted
|
||||
continue
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue