Browse Source

BUGFIX: Consider HTTP downloads >1MB as invalid .torrent files and abort them

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
1ea7340111
  1. 1
      Changelog
  2. 2
      src/bittorrent.cpp
  3. 28
      src/downloadthread.cpp
  4. 4
      src/downloadthread.h

1
Changelog

@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
- FEATURE: Support for multiple scan folders (Patch by Christian Kandeler)
- BUGFIX: Only one log window can be opened at a time
- BUGFIX: Optimized RSS module memory usage
- BUGFIX: Consider HTTP downloads >1MB as invalid .torrent files and abort
- COSMETIC: Improved style management
* Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0

2
src/bittorrent.cpp

@ -2163,7 +2163,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { @@ -2163,7 +2163,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
);
//emit aboutToDownloadFromUrl(url);
// Launch downloader thread
downloader->downloadUrl(url);
downloader->downloadTorrentUrl(url);
}
void Bittorrent::downloadFromURLList(const QStringList& urls) {

28
src/downloadthread.cpp

@ -95,7 +95,12 @@ void downloadThread::processDlFinished(QNetworkReply* reply) { @@ -95,7 +95,12 @@ void downloadThread::processDlFinished(QNetworkReply* reply) {
reply->deleteLater();
}
void downloadThread::downloadUrl(QString url){
void downloadThread::downloadTorrentUrl(QString url){
QNetworkReply *reply = downloadUrl(url);
connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(checkDownloadSize(qint64,qint64)));
}
QNetworkReply* downloadThread::downloadUrl(QString url){
// Update proxy settings
applyProxySettings();
// Process download request
@ -105,7 +110,26 @@ void downloadThread::downloadUrl(QString url){ @@ -105,7 +110,26 @@ void downloadThread::downloadUrl(QString url){
// Web server banning
request.setRawHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5");
qDebug("Downloading %s...", qPrintable(request.url().toString()));
networkManager->get(request);
return networkManager->get(request);
}
void downloadThread::checkDownloadSize(qint64 bytesReceived, qint64 bytesTotal) {
if(bytesTotal > 0) {
QNetworkReply *reply = static_cast<QNetworkReply*>(sender());
// Total number of bytes is available
if(bytesTotal > 1048576) {
// More than 1MB, this is probably not a torrent file, aborting...
reply->abort();
} else {
disconnect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(checkDownloadSize(qint64,qint64)));
}
} else {
if(bytesReceived > 1048576) {
// More than 1MB, this is probably not a torrent file, aborting...
QNetworkReply *reply = static_cast<QNetworkReply*>(sender());
reply->abort();
}
}
}
void downloadThread::applyProxySettings() {

4
src/downloadthread.h

@ -51,7 +51,8 @@ signals: @@ -51,7 +51,8 @@ signals:
public:
downloadThread(QObject* parent);
~downloadThread();
void downloadUrl(QString url);
QNetworkReply* downloadUrl(QString url);
void downloadTorrentUrl(QString url);
//void setProxy(QString IP, int port, QString username, QString password);
protected:
@ -60,6 +61,7 @@ protected: @@ -60,6 +61,7 @@ protected:
protected slots:
void processDlFinished(QNetworkReply* reply);
void checkDownloadSize(qint64 bytesReceived, qint64 bytesTotal);
};

Loading…
Cancel
Save