Permalink
Browse files

check for a valid picture before caching

  • Loading branch information...
1 parent f1a2bab commit f94c833ec8c8222e2b13ee44185c92b3f8ae15c9 Jonathan Marshall committed Mar 30, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 xbmc/TextureCacheJob.cpp
@@ -30,6 +30,7 @@
#include "utils/URIUtils.h"
#include "utils/StringUtils.h"
#include "URL.h"
+#include "FileItem.h"
CTextureCacheJob::CTextureCacheJob(const CStdString &url, const CStdString &oldHash)
{
@@ -107,6 +108,12 @@ CStdString CTextureCacheJob::CacheImage(const CStdString &url, const CStdString
if (hash.IsEmpty() || hash == oldHash)
return hash;
+ // Validate file URL to see if it is an image
+ CFileItem file(image, false);
+ if (!(file.IsPicture() && !(file.IsZIP() || file.IsRAR() || file.IsCBR() || file.IsCBZ() ))
+ && !file.GetMimeType().Left(6).Equals("image/")) // ignore non-pictures
+ return "";
+
CStdString logMessage = oldHash.IsEmpty() ? "Caching" : "Recaching";
CStdString cacheURL = CTextureCache::GetCachedPath(cacheFile);
if (flipped)

4 comments on commit f94c833

@theuni
Collaborator
theuni commented on f94c833 Apr 3, 2012

Could use !IsArchive so that future archive types are picked up here?

@jmarshallnz
Owner

Good idea - will check it out.

@jmarshallnz
Owner

IsArchive() doesn't exist yet (we do have IsInArchive) so I'll leave as-is for now.

@theuni
Collaborator
theuni commented on f94c833 Apr 3, 2012

Hmm, could've sworn we did. Ok, will add that in as it'd be worth having in other places.

Please sign in to comment.