Commit cb643c53 authored by Joris Guisson's avatar Joris Guisson
Browse files

Use file contents to figure out which type of blocklist we are dealing with in IP filter

BUG: 315239
parent b262bba2
......@@ -12,6 +12,7 @@ Changes in 4.4:
- Fix queue order not reflecting reality in some circumstances (308579)
- Use enclosure urls ending with .torrent in the syndication plugin
- Fix bug causing tab counts not to be initialized when QM is disabled (313737)
- Use file contents to figure out which type of blocklist we are dealing with in IP filter (315239)
Changes in 4.3.1:
- Fix new custom groups not appearing in add to group submenu (307230)
......
......@@ -113,7 +113,7 @@ namespace kt
QString temp = kt::DataDir() + "tmp-" + url.fileName();
//now determine if it's ZIP or TXT file
KMimeType::Ptr ptr = KMimeType::findByPath(temp);
KMimeType::Ptr ptr = KMimeType::findByFileContent(temp);
if (ptr->name() == "application/zip")
{
active_job = KIO::file_move(temp, QString(kt::DataDir() + QLatin1String("level1.zip")), -1, KIO::HideProgressInfo | KIO::Overwrite);
......@@ -125,11 +125,22 @@ namespace kt
connect(active_job, SIGNAL(result(KJob*)), this, SLOT(convert(KJob*)));
active_job->start();
}
else
else if(!KMimeType::isBinaryData(temp))
{
active_job = KIO::file_move(temp, QString(kt::DataDir() + "level1.txt"), -1, KIO::HideProgressInfo | KIO::Overwrite);
connect(active_job, SIGNAL(result(KJob*)), this, SLOT(convert(KJob*)));
}
else
{
QString msg = i18n("Cannot determine file type of <b>%1</b>", url.prettyUrl());
if (mode == Verbose)
KMessageBox::error(0, msg);
else
notification(msg);
setError(UNZIP_FAILED);
emitResult();
}
}
void DownloadAndConvertJob::extract(KJob* j)
......@@ -174,23 +185,10 @@ namespace kt
}
QString destination = kt::DataDir() + "level1.txt";
if (zip->directory()->entries().contains("splist.txt"))
{
active_job = new bt::ExtractFileJob(zip, "splist.txt", destination);
connect(active_job, SIGNAL(result(KJob*)), this, SLOT(convert(KJob*)));
unzip = true;
active_job->start();
}
else if (zip->directory()->entries().contains("level1.txt"))
{
active_job = new bt::ExtractFileJob(zip, "level1.txt", destination);
connect(active_job, SIGNAL(result(KJob*)), this, SLOT(convert(KJob*)));
unzip = true;
active_job->start();
}
else if (zip->directory()->entries().contains("ipfilter.dat"))
QStringList entries = zip->directory()->entries();
if(entries.count() >= 1)
{
active_job = new bt::ExtractFileJob(zip, "ipfilter.dat", destination);
active_job = new bt::ExtractFileJob(zip, entries.front(), destination);
connect(active_job, SIGNAL(result(KJob*)), this, SLOT(convert(KJob*)));
unzip = true;
active_job->start();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment