From 0eb35874c48b3078782af671a21ede98f4f92093 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Tue, 23 Oct 2018 10:59:41 +0200 Subject: back to http, but with input validation --- src/tikzit.cpp | 16 +++++++++------- src/tikzit.h | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/tikzit.cpp b/src/tikzit.cpp index 02b8578..820b8ec 100644 --- a/src/tikzit.cpp +++ b/src/tikzit.cpp @@ -363,7 +363,7 @@ void Tikzit::checkForUpdates() connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(updateReply(QNetworkReply*))); - manager->get(QNetworkRequest(QUrl("https://tikzit.github.io/latest-version.txt"))); + manager->get(QNetworkRequest(QUrl("http://tikzit.github.io/latest-version.txt"))); } void Tikzit::updateReply(QNetworkReply *reply) @@ -373,9 +373,6 @@ void Tikzit::updateReply(QNetworkReply *reply) QByteArray data = reply->read(200); QString strLatest = QString::fromUtf8(data).simplified(); - QVersionNumber current = QVersionNumber::fromString(TIKZIT_VERSION).normalized(); - QVersionNumber latest = QVersionNumber::fromString(strLatest).normalized(); - // check for valid version string and capture optional RC suffix QRegularExpression re("^[1-9]+(\\.[0-9]+)*(-[rR][cC]([0-9]+))?$"); QRegularExpressionMatch m; @@ -387,12 +384,17 @@ void Tikzit::updateReply(QNetworkReply *reply) m = re.match(strLatest); if (m.hasMatch()) { - int rcLatest = (!m.captured(3).isEmpty()) ? m.captured(3).toInt() : 1000; + QVersionNumber current = QVersionNumber::fromString(TIKZIT_VERSION).normalized(); + QVersionNumber latest = QVersionNumber::fromString(strLatest).normalized(); - //qDebug() << "latest" << latest << "rc" << rcLatest; - //qDebug() << "current" << current << "rc" << rcCurrent; + int rcLatest = (!m.captured(3).isEmpty()) ? m.captured(3).toInt() : 1000; if (latest > current || (latest == current && rcLatest > rcCurrent)) { + // give the version string in standard format + strLatest = QString::number(latest.majorVersion()) + "." + + QString::number(latest.minorVersion()) + "." + + QString::number(latest.microVersion()); + if (rcLatest != 1000) strLatest += "-rc" + QString::number(rcLatest); QMessageBox::information(0, tr("Update available"), "

A new version of TikZiT is available!

" diff --git a/src/tikzit.h b/src/tikzit.h index 69e9237..d36a940 100644 --- a/src/tikzit.h +++ b/src/tikzit.h @@ -49,7 +49,7 @@ #ifndef TIKZIT_H #define TIKZIT_H -#define TIKZIT_VERSION "2.0" +#define TIKZIT_VERSION "2.0.0" #include "mainwindow.h" #include "mainmenu.h" -- cgit v1.2.3