Changeset - e2b9731cb2fb
[Not reviewed]
default
0 1 0
Mads Kiilerich - 6 years ago 2019-11-09 19:13:41
mads@kiilerich.com
Grafted from: 1d6bfaf60b96
search: fix "'' is not unicode" when searching for wildcards

Seen when search matches on an empty list of unicode matches and the joining ''
thus isn't coerced to u'' - seen for example on
http://localhost:5000/_admin/search?q=*a*&type=content .
1 file changed with 1 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/indexers/__init__.py
Show inline comments
 
@@ -194,26 +194,25 @@ class WhooshResultWrapper(object):
 
            full_repo_path = os.path.join(self.repo_location, res['repository'])
 
            f_path = res['path'].split(full_repo_path)[-1]
 
            f_path = f_path.lstrip(os.sep)
 
            res.update({'f_path': f_path})
 
        elif self.search_type == 'message':
 
            res.update({'message_hl': self.highlight(res['message'])})
 

	
 
        log.debug('result: %s', res)
 

	
 
        return res
 

	
 
    def get_short_content(self, res, chunks):
 

	
 
        return ''.join([res['content'][chunk[0]:chunk[1]] for chunk in chunks])
 
        return u''.join([res['content'][chunk[0]:chunk[1]] for chunk in chunks])
 

	
 
    def get_chunks(self):
 
        """
 
        Smart function that implements chunking the content
 
        but not overlap chunks so it doesn't highlight the same
 
        close occurrences twice.
 
        """
 
        memory = [(0, 0)]
 
        if self.matcher.supports('positions'):
 
            for span in self.matcher.spans():
 
                start = span.startchar or 0
 
                end = span.endchar or 0
0 comments (0 inline, 0 general)