From 49b57904f98f6cfd06f04daf49c46c714a71621a Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 17 Apr 2019 20:09:03 +0800 Subject: [PATCH] Use a random number for WebUI cache busting Also fetch qbt version info via WebAPI properly. --- src/webui/webapplication.cpp | 3 ++- src/webui/webapplication.h | 1 + src/webui/www/private/about.html | 6 ++++- src/webui/www/private/addtrackers.html | 2 +- src/webui/www/private/confirmdeletion.html | 2 +- src/webui/www/private/download.html | 8 +++---- src/webui/www/private/downloadlimit.html | 4 ++-- src/webui/www/private/edittracker.html | 2 +- src/webui/www/private/index.html | 28 +++++++++++----------- src/webui/www/private/newcategory.html | 4 ++-- src/webui/www/private/preferences.html | 4 ++-- src/webui/www/private/rename.html | 4 ++-- src/webui/www/private/scripts/client.js | 23 ++++++++++++++++-- src/webui/www/private/setlocation.html | 4 ++-- src/webui/www/private/shareratio.html | 4 ++-- src/webui/www/private/upload.html | 6 ++--- src/webui/www/private/uploadlimit.html | 4 ++-- src/webui/www/public/index.html | 6 ++--- 18 files changed, 70 insertions(+), 45 deletions(-) diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp index a6f28b00b..ef2202b1b 100644 --- a/src/webui/webapplication.cpp +++ b/src/webui/webapplication.cpp @@ -117,6 +117,7 @@ namespace WebApplication::WebApplication(QObject *parent) : QObject(parent) + , m_cacheID {QString::number(Utils::Random::rand(), 36)} { registerAPIController(QLatin1String("app"), new AppController(this, this)); registerAPIController(QLatin1String("auth"), new AuthController(this, this)); @@ -225,7 +226,7 @@ void WebApplication::translateDocument(QString &data) } data.replace(QLatin1String("${LANG}"), m_currentLocale.left(2)); - data.replace(QLatin1String("${VERSION}"), QBT_VERSION); + data.replace(QLatin1String("${CACHEID}"), m_cacheID); } } diff --git a/src/webui/webapplication.h b/src/webui/webapplication.h index 2c3c78f5f..1c38d65b8 100644 --- a/src/webui/webapplication.h +++ b/src/webui/webapplication.h @@ -127,6 +127,7 @@ private: Http::Request m_request; Http::Environment m_env; QMap m_params; + const QString m_cacheID; const QRegularExpression m_apiPathPattern {(QLatin1String("^/api/v2/(?[A-Za-z_][A-Za-z_0-9]*)/(?[A-Za-z_][A-Za-z_0-9]*)$"))}; diff --git a/src/webui/www/private/about.html b/src/webui/www/private/about.html index 43f378b78..e2f783c12 100644 --- a/src/webui/www/private/about.html +++ b/src/webui/www/private/about.html @@ -1,6 +1,6 @@
qBittorrent Mascot -

qBittorrent ${VERSION} QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog]

+

QBT_TR(An advanced BitTorrent client programmed in C++, based on Qt toolkit and libtorrent-rasterbar.)QBT_TR[CONTEXT=AboutDialog]

Copyright (c) 2011-2019 The qBittorrent project

QBT_TR(Home Page:)QBT_TR[CONTEXT=AboutDialog] https://www.qbittorrent.org

@@ -676,6 +676,10 @@ - - + + diff --git a/src/webui/www/private/downloadlimit.html b/src/webui/www/private/downloadlimit.html index aef12f5e2..926af0824 100644 --- a/src/webui/www/private/downloadlimit.html +++ b/src/webui/www/private/downloadlimit.html @@ -4,11 +4,11 @@ QBT_TR(Torrent Download Speed Limiting)QBT_TR[CONTEXT=TransferListWidget] - + - + diff --git a/src/webui/www/private/edittracker.html b/src/webui/www/private/edittracker.html index 10f575a5c..53cc2b861 100644 --- a/src/webui/www/private/edittracker.html +++ b/src/webui/www/private/edittracker.html @@ -4,7 +4,7 @@ QBT_TR(Tracker editing)QBT_TR[CONTEXT=TrackerListWidget] - + - + - - - - - + + + + + diff --git a/src/webui/www/private/newcategory.html b/src/webui/www/private/newcategory.html index 18e205c61..04dd6e447 100644 --- a/src/webui/www/private/newcategory.html +++ b/src/webui/www/private/newcategory.html @@ -4,10 +4,10 @@ QBT_TR(New Category)QBT_TR[CONTEXT=TransferListWidget] - + - + diff --git a/src/webui/www/private/rename.html b/src/webui/www/private/rename.html index 4857e8388..ebc0ff618 100644 --- a/src/webui/www/private/rename.html +++ b/src/webui/www/private/rename.html @@ -4,10 +4,10 @@ QBT_TR(Rename)QBT_TR[CONTEXT=TransferListWidget] - + - + - + - + - + diff --git a/src/webui/www/private/uploadlimit.html b/src/webui/www/private/uploadlimit.html index 6c9e1f873..f4c147596 100644 --- a/src/webui/www/private/uploadlimit.html +++ b/src/webui/www/private/uploadlimit.html @@ -4,11 +4,11 @@ QBT_TR(Torrent Upload Speed Limiting)QBT_TR[CONTEXT=TransferListWidget] - + - + diff --git a/src/webui/www/public/index.html b/src/webui/www/public/index.html index cc9ce0226..8fcdd948f 100644 --- a/src/webui/www/public/index.html +++ b/src/webui/www/public/index.html @@ -5,11 +5,11 @@ qBittorrent QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog] - + - +