From 5374315e76e7b2ddca5fae8e45b19449d28a4f53 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Mon, 25 Jun 2012 20:45:37 +0200 Subject: [PATCH] Only allow directories for directorylisting --- servefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/servefile b/servefile index 2903953..93124d9 100755 --- a/servefile +++ b/servefile @@ -871,13 +871,17 @@ class ServeFile(): try: os.mkdir(self.target) except (IOError, OSError): - raise ServeFileException("Error: Could not create directory '%s' for uploads." % (self.target,) ) + raise ServeFileException("Error: Could not create directory '%s' for uploads." % (self.target,)) else: raise ServeFileException("Error: Upload directory already exists and is a file.") FilePutter.targetDir = self.target FilePutter.maxUploadSize = self.maxUploadSize handler = FilePutter elif self.serveMode == self.MODE_LISTDIR: + if not os.path.exists(self.target): + raise ServeFileException("Error: Could not open file or directory.") + if not os.path.isdir(self.target): + raise ServeFileException("Error: '%s' is not a directory." % (self.target,)) handler = DirListingHandler handler.targetDir = self.target