From dd053f87f91ea86c90b38081544b09964cc9cc79 Mon Sep 17 00:00:00 2001 From: Albert S Date: Sat, 19 Dec 2020 12:51:52 +0100 Subject: [PATCH] shared: qssquery: checkParanthesis(): Ignore paranthesis in quotes Fixes #12 --- shared/qssquery.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/shared/qssquery.cpp b/shared/qssquery.cpp index 3bdbef0..132e238 100644 --- a/shared/qssquery.cpp +++ b/shared/qssquery.cpp @@ -34,16 +34,25 @@ bool QSSQuery::checkParanthesis(QString expression) QStack open; QStack close; + bool inQuotes = false; + for(QChar &c : expression) { - if(c == '(') - { - open.push(c); - } - if(c == ')') - { - close.push(c); - } + if(!inQuotes) + { + if(c == '(') + { + open.push(c); + } + if(c == ')') + { + close.push(c); + } + } + if(c == '"') + { + inQuotes = ! inQuotes; + } } if(open.size() != close.size()) {