From 1f35e2120e3b0c534defe16c61687bfc94d12665 Mon Sep 17 00:00:00 2001 From: Albert S Date: Tue, 4 Jan 2022 11:07:59 +0100 Subject: [PATCH] LooqsQuery::build(): Ensure values are non-empty and ignore empty lone words --- shared/looqsquery.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shared/looqsquery.cpp b/shared/looqsquery.cpp index 6cb4567..5416da8 100644 --- a/shared/looqsquery.cpp +++ b/shared/looqsquery.cpp @@ -251,6 +251,10 @@ LooqsQuery LooqsQuery::build(QString expression, TokenType loneWordsTokenType, b { value = m.captured("args"); } + if(value == "") + { + throw LooqsGeneralException("value cannot be empty for filters"); + } if(filtername == "path.contains") { @@ -301,7 +305,11 @@ LooqsQuery LooqsQuery::build(QString expression, TokenType loneWordsTokenType, b if(mergeLoneWords) { - result.addToken(Token(loneWordsTokenType, loneWords.join(' '))); + QString mergedLoneWords = loneWords.join(' '); + if(!mergedLoneWords.isEmpty()) + { + result.addToken(Token(loneWordsTokenType, mergedLoneWords)); + } } bool contentsearch = (result.getTokensMask() & FILTER_CONTENT) == FILTER_CONTENT;