[kupfer: 3/27] archiveinside: Don't allow looking inside too big archives



commit 12c32150b586cabf9cb082a745a20dc9653dceb8
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Fri Jan 22 17:31:33 2010 +0100

    archiveinside: Don't allow looking inside too big archives

 kupfer/plugin/archiveinside.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/kupfer/plugin/archiveinside.py b/kupfer/plugin/archiveinside.py
index 4db3865..7d47e72 100644
--- a/kupfer/plugin/archiveinside.py
+++ b/kupfer/plugin/archiveinside.py
@@ -4,7 +4,6 @@ drill down into compressed archives.
 
 Issues to resolve:
 
- * Refuse looking into archives over a certain size
  * Add option to clean up at Kupfer's exit
  * Handle zip, tar.gz and anything we can
 """
@@ -22,6 +21,8 @@ from kupfer.objects import Source, FileLeaf
 from kupfer.obj.sources import DirectorySource
 from kupfer import utils
 
+# Limit this to archives of a couple of megabytes
+MAX_ARCHIVE_BYTE_SIZE = 15 * 1024**2
 
 
 class ArchiveContent (Source):
@@ -60,6 +61,8 @@ class ArchiveContent (Source):
 	def decorate_item(cls, leaf):
 		root, ext = os.path.splitext(leaf.object)
 		if leaf.object.lower().endswith(".tar.gz"):
-			return cls(leaf)
+			byte_size = os.stat(leaf.object).st_size
+			if byte_size < MAX_ARCHIVE_BYTE_SIZE:
+				return cls(leaf)
 		return None
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]