Conf: Fix parsing app paths with spaces.

This commit is contained in:
Nodir Temirkhodjaev 2017-12-15 13:43:06 +05:00
parent 3e23cc8342
commit 2b19aef2f5
2 changed files with 5 additions and 4 deletions

View File

@ -36,7 +36,7 @@ void Test::confWriteRead()
"System" "System"
); );
appGroup1->setAllowText( appGroup1->setAllowText(
"C:\\Programs\\Skype\\Phone\\Skype.exe\n" "C:\\Program Files\\Skype\\Phone\\Skype.exe\n"
"C:\\Utils\\Dev\\Git\\\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::confIpInRange(data, NetUtil::textToIp4("193.0.0.0")));
QVERIFY(FortCommon::confAppBlocked(data, "System")); 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:\\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())); QVERIFY(FortCommon::confAppBlocked(data, FileUtil::pathToKernelPath("C:\\Utils\\Firefox\\Bin\\firefox.exe").toLower()));
} }

View File

@ -181,13 +181,13 @@ bool ConfUtil::parseApps(const QString &text, bool blocked,
QString ConfUtil::parseAppPath(const QStringRef &line) 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); const QRegularExpressionMatch match = re.match(line);
if (!match.hasMatch()) if (!match.hasMatch())
return QString(); return QString();
const QStringRef path = match.capturedRef(1); const QStringRef path = match.capturedRef(1).trimmed();
const QString systemPath("System"); const QString systemPath("System");
if (!QStringRef::compare(path, systemPath, Qt::CaseInsensitive)) if (!QStringRef::compare(path, systemPath, Qt::CaseInsensitive))