From 9dfc35527b20ef44846578259452f7cd6fe58d7b Mon Sep 17 00:00:00 2001 From: luisangelsm Date: Mon, 30 Mar 2026 20:17:05 +0200 Subject: [PATCH] Fix version checking --- common/check_new_version.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/common/check_new_version.cpp b/common/check_new_version.cpp index d8a8bf9e..00e3c0fc 100644 --- a/common/check_new_version.cpp +++ b/common/check_new_version.cpp @@ -11,8 +11,6 @@ #include #include -#define PREVIOUS_VERSION_TESTING "6.0.0" - HttpVersionChecker::HttpVersionChecker() : HttpWorker("https://raw.githubusercontent.com/YACReader/yacreader/master/VERSION", DEFAULT_USER_AGENT) { @@ -26,12 +24,17 @@ void HttpVersionChecker::checkNewVersion(const QByteArray &data) bool HttpVersionChecker::checkNewVersion(QString sourceContent) { -#ifdef QT_DEBUG - const auto currentVersion = QVersionNumber::fromString(PREVIOUS_VERSION_TESTING); -#else + const auto currentVersion = QVersionNumber::fromString(QString::fromLatin1(VERSION)); -#endif - const auto latestVersion = QVersionNumber::fromString(sourceContent.trimmed()); + const auto trimmedSourceContent = sourceContent.trimmed(); + qsizetype suffixIndex = 0; + const auto latestVersion = QVersionNumber::fromString(trimmedSourceContent, &suffixIndex); + + if (trimmedSourceContent.isEmpty() || + suffixIndex != trimmedSourceContent.size() || + latestVersion.segments().size() != 3) { + return false; + } if (!currentVersion.isNull() && !latestVersion.isNull() && QVersionNumber::compare(latestVersion, currentVersion) > 0) { emit newVersionDetected();