search: goto commit search will now use a safe search option and never
throw any exceptions even if search is misconfigured. Fixes #5193
This commit is contained in:
parent
f8f9bdc988
commit
af493443e3
3 changed files with 11 additions and 6 deletions
|
|
@ -178,7 +178,8 @@ class HomeController(BaseController):
|
|||
user_id=c.rhodecode_user.user_id, ip_addr=self.ip_addr)
|
||||
searcher = searcher_from_config(config)
|
||||
result = searcher.search(
|
||||
'commit_id:%s*' % commit_hash_prefix, 'commit', auth_user)
|
||||
'commit_id:%s*' % commit_hash_prefix, 'commit', auth_user,
|
||||
raise_on_exc=False)
|
||||
|
||||
return [
|
||||
{
|
||||
|
|
@ -187,7 +188,8 @@ class HomeController(BaseController):
|
|||
'type': 'commit',
|
||||
'obj': {'repo': entry['repository']},
|
||||
'url': url('changeset_home',
|
||||
repo_name=entry['repository'], revision=entry['commit_id'])
|
||||
repo_name=entry['repository'],
|
||||
revision=entry['commit_id'])
|
||||
}
|
||||
for entry in result['results']]
|
||||
|
||||
|
|
|
|||
|
|
@ -39,9 +39,11 @@ class BaseSearch(object):
|
|||
def cleanup(self):
|
||||
pass
|
||||
|
||||
def search(self, query, document_type, search_user, repo_name=None):
|
||||
def search(self, query, document_type, search_user, repo_name=None,
|
||||
raise_on_exc=True):
|
||||
raise Exception('NotImplemented')
|
||||
|
||||
|
||||
def searcher_from_config(config, prefix='search.'):
|
||||
_config = {}
|
||||
for key in config.keys():
|
||||
|
|
|
|||
|
|
@ -60,12 +60,12 @@ FRAGMENTER = ContextFragmenter(200)
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
class Search(BaseSearch):
|
||||
|
||||
name = 'whoosh'
|
||||
|
||||
def __init__(self, config):
|
||||
super(Search, self).__init__()
|
||||
self.config = config
|
||||
if not os.path.isdir(self.config['location']):
|
||||
os.makedirs(self.config['location'])
|
||||
|
|
@ -99,8 +99,9 @@ class Search(BaseSearch):
|
|||
query = u'(%s) OR %s' % (query, hashes_or_query)
|
||||
return query
|
||||
|
||||
def search(self, query, document_type, search_user, repo_name=None,
|
||||
requested_page=1, page_limit=10, sort=None):
|
||||
def search(self, query, document_type, search_user,
|
||||
repo_name=None, requested_page=1, page_limit=10, sort=None,
|
||||
raise_on_exc=True):
|
||||
|
||||
original_query = query
|
||||
query = self._extend_query(query)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue