]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/search/dolphinquery.cpp
[search] Fix corner cases when using quotes in filenames
[dolphin.git] / src / search / dolphinquery.cpp
index 0581a02ece041fcc242ca13388d72131ca5e44d4..663ed9909ded157bf6df0a1a560024dae79ee576 100644 (file)
@@ -59,7 +59,11 @@ namespace {
 
     QStringList splitOutsideQuotes(const QString& text)
     {
-        const QRegularExpression subTermsRegExp("(\\S*?\"[^\"]*?\"|(?<=\\s|^)\\S+(?=\\s|$))");
+        // Match groups on 3 possible conditions:
+        //   - Groups with two leading quotes must close both on them (filename:""abc xyz" tuv")
+        //   - Groups enclosed in quotes
+        //   - Words separated by spaces
+        const QRegularExpression subTermsRegExp("(\\S*?\"\"[^\"]+\"[^\"]+\"+|\\S*?\"[^\"]+\"+|(?<=\\s|^)\\S+(?=\\s|$))");
         auto subTermsMatchIterator = subTermsRegExp.globalMatch(text);
 
         QStringList textParts;