server/search: change named token detection

In particular, treat tokens starting with : as anonymous tokens.
This commit is contained in:
rr- 2016-05-24 10:29:14 +02:00
parent af22ec735d
commit 731c0442e9
2 changed files with 5 additions and 1 deletions

View file

@ -58,7 +58,7 @@ class SearchExecutor(object):
token = token[1:]
negated = not negated
if ':' in token:
if ':' in token and token[0] != ':':
key, value = token.split(':', 2)
query = self._handle_key_value(query, key, value, negated)
else:

View file

@ -29,6 +29,10 @@ def test_filter_anonymous(verify_unpaged, tag_factory, input, expected_tag_names
db.session.add(tag_factory(names=['t2']))
verify_unpaged(input, expected_tag_names)
def test_filter_anonymous_starting_with_colon(verify_unpaged, tag_factory):
db.session.add(tag_factory(names=[':t']))
verify_unpaged(':t', [':t'])
@pytest.mark.parametrize('input,expected_tag_names', [
('name:tag1', ['tag1']),
('name:tag2', ['tag2']),