1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-22 12:34:19 +00:00

Improve path validness test

This commit is contained in:
Chocobo1 2022-07-27 01:14:03 +08:00
parent 17d40855d2
commit 43df7d0cd4
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C

View File

@ -76,12 +76,14 @@ bool Path::isValid() const
if (isEmpty())
return false;
// https://stackoverflow.com/a/31976060
#if defined(Q_OS_WIN)
const QRegularExpression regex {u"[:?\"*<>|]"_qs};
// \\37 is using base-8 number system
const QRegularExpression regex {u"[\\0-\\37:?\"*<>|]"_qs};
#elif defined(Q_OS_MACOS)
const QRegularExpression regex {u"[\\0:]"_qs};
#else
const QRegularExpression regex {u"[\\0]"_qs};
const QRegularExpression regex {u"\\0"_qs};
#endif
return !m_pathStr.contains(regex);
}