From 2b19aef2f5858f45c3e654004d4c2952f6f2568f Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Fri, 15 Dec 2017 13:43:06 +0500 Subject: [PATCH] Conf: Fix parsing app paths with spaces. --- src/tests/confutil/test.cpp | 5 +++-- src/ui/util/confutil.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tests/confutil/test.cpp b/src/tests/confutil/test.cpp index ebc0fc67..750a29a3 100644 --- a/src/tests/confutil/test.cpp +++ b/src/tests/confutil/test.cpp @@ -36,7 +36,7 @@ void Test::confWriteRead() "System" ); appGroup1->setAllowText( - "C:\\Programs\\Skype\\Phone\\Skype.exe\n" + "C:\\Program Files\\Skype\\Phone\\Skype.exe\n" "C:\\Utils\\Dev\\Git\\\n" ); @@ -68,7 +68,8 @@ void Test::confWriteRead() QVERIFY(!FortCommon::confIpInRange(data, NetUtil::textToIp4("193.0.0.0"))); QVERIFY(FortCommon::confAppBlocked(data, "System")); - QVERIFY(!FortCommon::confAppBlocked(data, FileUtil::pathToKernelPath("C:\\Programs\\Skype\\Phone\\Skype.exe").toLower())); + QVERIFY(!FortCommon::confAppBlocked(data, FileUtil::pathToKernelPath("C:\\Program Files\\Skype\\Phone\\Skype.exe").toLower())); QVERIFY(!FortCommon::confAppBlocked(data, FileUtil::pathToKernelPath("C:\\Utils\\Dev\\Git\\").toLower())); + QVERIFY(FortCommon::confAppBlocked(data, FileUtil::pathToKernelPath("C:\\Program Files\\Test.exe").toLower())); QVERIFY(FortCommon::confAppBlocked(data, FileUtil::pathToKernelPath("C:\\Utils\\Firefox\\Bin\\firefox.exe").toLower())); } diff --git a/src/ui/util/confutil.cpp b/src/ui/util/confutil.cpp index 4c89dab2..39c207c8 100644 --- a/src/ui/util/confutil.cpp +++ b/src/ui/util/confutil.cpp @@ -181,13 +181,13 @@ bool ConfUtil::parseApps(const QString &text, bool blocked, QString ConfUtil::parseAppPath(const QStringRef &line) { - const QRegularExpression re("\\s*\"?\\s*(\\S+)\\s*\"?\\s*"); + const QRegularExpression re("\\s*\"?\\s*([^\"]+)\\s*\"?\\s*"); const QRegularExpressionMatch match = re.match(line); if (!match.hasMatch()) return QString(); - const QStringRef path = match.capturedRef(1); + const QStringRef path = match.capturedRef(1).trimmed(); const QString systemPath("System"); if (!QStringRef::compare(path, systemPath, Qt::CaseInsensitive))