summaryrefslogtreecommitdiffstats
path: root/tdenewstuff/knewstuffgeneric.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-10-07 15:35:07 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-10-07 15:35:07 -0500
commit30c2b7e4bd6fa63d0f3431b8e82fefd81364726f (patch)
treedb230ec7e83392ce981cd80912a2b4fdf6f3a206 /tdenewstuff/knewstuffgeneric.cpp
parente5f898219af927c9bac3aa9b0c9e9473a52dde15 (diff)
downloadtdelibs-30c2b7e4bd6fa63d0f3431b8e82fefd81364726f.tar.gz
tdelibs-30c2b7e4bd6fa63d0f3431b8e82fefd81364726f.zip
Autodetect downloaded mime type and compare against category; if wallpaper downloads something other than image abort
This relates to Bug 2127
Diffstat (limited to 'tdenewstuff/knewstuffgeneric.cpp')
-rw-r--r--tdenewstuff/knewstuffgeneric.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tdenewstuff/knewstuffgeneric.cpp b/tdenewstuff/knewstuffgeneric.cpp
index 16fda977c..757971268 100644
--- a/tdenewstuff/knewstuffgeneric.cpp
+++ b/tdenewstuff/knewstuffgeneric.cpp
@@ -29,6 +29,7 @@
#include <tdeconfig.h>
#include <kstandarddirs.h>
#include <tdemessagebox.h>
+#include <kmimemagic.h>
#include <ktar.h>
#include "entry.h"
@@ -49,6 +50,18 @@ TDENewStuffGeneric::~TDENewStuffGeneric()
bool TDENewStuffGeneric::install( const TQString &fileName )
{
+ // Try to detect the most common cases where (usually adware) Web pages are downloaded
+ // instead of the desired file and abort
+ KMimeMagicResult *res = KMimeMagic::self()->findFileType( fileName );
+ if ( res->isValid() && res->accuracy() > 40 ) {
+ if (type().lower().contains("wallpaper")) {
+ if (!res->mimeType().startsWith("image/")) {
+ TQFile::remove(fileName);
+ return false;
+ }
+ }
+}
+
kdDebug() << "TDENewStuffGeneric::install(): " << fileName << endl;
TQStringList list, list2;