Changeset - 552f6738ace2
[Not reviewed]
default
0 1 0
Mads Kiilerich (kiilerix) - 5 years ago 2019-11-20 11:55:14
mads@kiilerich.com
search: avoid crash when making (odd) search for '*'

Crashed in whoosh ListMatcher.supports() on
def supports(self, astype):
return self._format.supports(astype)
with
AttributeError: 'NoneType' object has no attribute 'supports'
on for example http://localhost:5000/_admin/search?q=*&type=content .

There doesn't seem to be a good way to detect if _format has been provided.
1 file changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general) First comment
kallithea/lib/indexers/__init__.py
Show inline comments
 
@@ -212,7 +212,11 @@ class WhooshResultWrapper(object):
 
        close occurrences twice.
 
        """
 
        memory = [(0, 0)]
 
        if self.matcher.supports('positions'):
 
        try:
 
            supports_positions = self.matcher.supports('positions')
 
        except AttributeError:  # 'NoneType' object has no attribute 'supports' (because matcher never get a format)
 
            supports_positions = False
 
        if supports_positions:
 
            for span in self.matcher.spans():
 
                start = span.startchar or 0
 
                end = span.endchar or 0
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now