Bug 392620 - Baloo parses queries like 'a AND ((b OR c) OR d) incorrectly
Summary: Baloo parses queries like 'a AND ((b OR c) OR d) incorrectly
Status: RESOLVED FIXED
Alias: None
Product: frameworks-baloo
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.44.0
Platform: Other All
: NOR normal
Target Milestone: ---
Assignee: baloo-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-01 22:07 UTC by Stefan Brüns
Modified: 2018-04-08 15:41 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Brüns 2018-04-01 22:07:48 UTC
The lexer in advancedqueryparser.cpp combines multiple consecutive operators. While this is correct for "<=" and ">=", it is wrong for all other operators.

As the (( is evaluated as a single opening brace, the query above is evaluated as '(a AND (b OR c)) OR d'.
Comment 1 Stefan Brüns 2018-04-08 15:40:25 UTC
Git commit 4e69ffeab75f81f9c50aa12bb34aba0a477ee23e by Stefan Brüns.
Committed on 08/04/2018 at 15:40.
Pushed by bruns into branch 'master'.

Add test case for parsing of double opening '(('

Summary:
Parsing of e.g. "a OR ((b AND c) AND d)" currently fails, as for
the opening '((' only one token is created by the lexer.

Test Plan:
```
QDEBUG : AdvancedQueryParserTest::testNestedParentheses(a OR ((b AND c) AND d))   result term [ OR ( : a (QString)) [ AND ( : b (QString)) ( : c (QString)) ] ( : d (QString)) ]
QDEBUG : AdvancedQueryParserTest::testNestedParentheses(a OR ((b AND c) AND d)) expected term [ OR ( : a (QString)) [ AND ( : b (QString)) ( : c (QString)) ( : d (QString)) ] ]
XFAIL  : AdvancedQueryParserTest::testNestedParentheses(a OR ((b AND c) AND d)) Opening '((' parsed incorrectly
```

Reviewers: #baloo, michaelh

Reviewed By: michaelh

Subscribers: #frameworks

Tags: #frameworks, #baloo

Differential Revision: https://phabricator.kde.org/D12007

M  +26   -1    autotests/unit/lib/advancedqueryparsertest.cpp

https://commits.kde.org/baloo/4e69ffeab75f81f9c50aa12bb34aba0a477ee23e
Comment 2 Stefan Brüns 2018-04-08 15:41:35 UTC
Git commit 116e55a2076e5dd3264be4ad8a06b6a2554b6fda by Stefan Brüns.
Committed on 08/04/2018 at 15:41.
Pushed by bruns into branch 'master'.

Handle adjacent special characters correctly

Summary:
The code handled sequences like '((' incorrectly, i.e. this was parsed as
a single opening quote, and thus could get operator association wrong.
Although only '>=' and '<=' have a special meaning, also accept '==' and
':=' as '=' resp. ':'.

Test Plan:
```
38: QDEBUG : AdvancedQueryParserTest::testNestedParentheses(a OR ((b AND c) AND d))   result term [ OR ( : a (QString)) [ AND ( : b (QString)) ( : c (QString)) ( : d (QString)) ] ]
38: QDEBUG : AdvancedQueryParserTest::testNestedParentheses(a OR ((b AND c) AND d)) expected term [ OR ( : a (QString)) [ AND ( : b (QString)) ( : c (QString)) ( : d (QString)) ] ]
38: PASS   : AdvancedQueryParserTest::testNestedParentheses(a OR ((b AND c) AND d))

```

Reviewers: #baloo, michaelh

Reviewed By: #baloo, michaelh

Subscribers: #frameworks

Tags: #frameworks, #baloo

Differential Revision: https://phabricator.kde.org/D11888

M  +1    -1    autotests/unit/lib/advancedqueryparsertest.cpp
M  +28   -39   src/lib/advancedqueryparser.cpp

https://commits.kde.org/baloo/116e55a2076e5dd3264be4ad8a06b6a2554b6fda