From 9814b132c3bfcd6134236376b43fbc1ad1df6088 Mon Sep 17 00:00:00 2001 From: rr- Date: Mon, 24 Apr 2017 19:55:02 +0200 Subject: [PATCH] server/search: fix searching for --- Allow only one negation sign. Also throw an error if user searches only for "-". --- server/szurubooru/search/parser.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/szurubooru/search/parser.py b/server/szurubooru/search/parser.py index 93affe26..6369bc6e 100644 --- a/server/szurubooru/search/parser.py +++ b/server/szurubooru/search/parser.py @@ -77,9 +77,11 @@ class Parser: if not chunk: continue negated = False - while chunk[0] == '-': + if chunk[0] == '-': chunk = chunk[1:] - negated = not negated + negated = True + if not chunk: + raise errors.SearchError('Empty negated token.') match = re.match('([a-z_-]+):(.*)', chunk) if match: key, value = list(match.groups())