From 43df7d0cd4bfb52c6581181b713ccf2eaef357ee Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 27 Jul 2022 01:14:03 +0800 Subject: [PATCH] Improve path validness test --- src/base/path.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/base/path.cpp b/src/base/path.cpp index 66270154c..bf8b8d481 100644 --- a/src/base/path.cpp +++ b/src/base/path.cpp @@ -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); }