mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-21 05:43:32 -07:00
fix: Add check for Content-Type when downloading tracker list.
Check if the URL from where we are downloading the trackers returns `Content-Type` as `text`. Otherwise consider it might be a non-usable format for this functionality (html,xml,etc.ect.)
This commit is contained in:
parent
663da093bd
commit
67db0c03d7
3 changed files with 9 additions and 0 deletions
|
@ -143,6 +143,7 @@ void Net::DownloadHandlerImpl::processFinishedDownload()
|
|||
#else
|
||||
m_result.data = m_reply->readAll();
|
||||
#endif
|
||||
m_result.contentType = m_reply->header(QNetworkRequest::ContentTypeHeader).toString();
|
||||
|
||||
if (m_downloadRequest.saveToFile())
|
||||
{
|
||||
|
|
|
@ -107,6 +107,7 @@ namespace Net
|
|||
QByteArray data;
|
||||
Path filePath;
|
||||
QString magnetURI;
|
||||
QString contentType;
|
||||
};
|
||||
|
||||
class DownloadHandler : public QObject
|
||||
|
|
|
@ -109,6 +109,13 @@ void TrackersAdditionDialog::onTorrentListDownloadFinished(const Net::DownloadRe
|
|||
m_ui->downloadButton->setEnabled(true);
|
||||
setCursor(Qt::ArrowCursor);
|
||||
|
||||
if (!result.contentType.contains(u"text/plain"_s, Qt::CaseInsensitive))
|
||||
{
|
||||
QMessageBox::warning(this, tr("Download trackers list error")
|
||||
, tr("The content type of the downloaded file is not plain text. Content-Type: \"%1\"").arg(result.contentType));
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.status != Net::DownloadStatus::Success)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Download trackers list error")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue