From 731c0442e9c681da8816e13eb943046e26a41095 Mon Sep 17 00:00:00 2001 From: rr- Date: Tue, 24 May 2016 10:29:14 +0200 Subject: [PATCH] server/search: change named token detection In particular, treat tokens starting with : as anonymous tokens. --- server/szurubooru/search/search_executor.py | 2 +- server/szurubooru/tests/search/test_tag_search_config.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server/szurubooru/search/search_executor.py b/server/szurubooru/search/search_executor.py index fc5d9c0a..fad2bed7 100644 --- a/server/szurubooru/search/search_executor.py +++ b/server/szurubooru/search/search_executor.py @@ -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: diff --git a/server/szurubooru/tests/search/test_tag_search_config.py b/server/szurubooru/tests/search/test_tag_search_config.py index 3b234337..e1d17866 100644 --- a/server/szurubooru/tests/search/test_tag_search_config.py +++ b/server/szurubooru/tests/search/test_tag_search_config.py @@ -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']),