StaticFile link-check

David Binger <dbinger-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Thu, 10 Feb 2005 21:41:25 -0500
Newsgroups gmane.comp.web.quixote.cvs
Message-ID <[email protected]>
--Apple-Mail-8-933466498
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

Move link-check from StaticFile constructor to __call__().

--Apple-Mail-8-933466498
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	x-unix-mode=0644;
	name="util_patch.txt"
Content-Disposition: attachment;
	filename=util_patch.txt

Index: util.py
===================================================================
--- util.py	(revision 26059)
+++ util.py	(working copy)
@@ -161,18 +161,18 @@
         self.path = path
         if not os.path.isabs(path):
             raise ValueError, "Path %r is not absolute" % path
-        if os.path.islink(path) and not follow_symlinks:
-            raise errors.TraversalError(private_msg="Path %r is a symlink"
-                                        % path)
-
         # Decide the Content-Type of the file
         guess_mime, guess_enc = mimetypes.guess_type(os.path.basename(path),
                                                      strict=False)
         self.mime_type = mime_type or guess_mime or 'text/plain'
         self.encoding = encoding or guess_enc or None
         self.cache_time = cache_time
+        self.follow_symlinks = follow_symlinks
 
     def __call__(self):
+        if not self.follow_symlinks and os.path.islink(self.path):
+            raise errors.TraversalError(private_msg="Path %r is a symlink"
+                                        % self.path)
         stat = os.stat(self.path)
         last_modified = formatdate(stat.st_mtime)
         request = quixote.get_request()

--Apple-Mail-8-933466498
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Quixote-checkins mailing list
Quixote-checkins-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]
http://mail.mems-exchange.org/mailman/listinfo/quixote-checkins

--Apple-Mail-8-933466498--