]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Attempt to fix StaticFileHandler when os.path.sep != '/'.
authorBen Darnell <ben@bendarnell.com>
Tue, 19 Oct 2010 21:12:33 +0000 (14:12 -0700)
committerBen Darnell <ben@bendarnell.com>
Tue, 19 Oct 2010 21:13:35 +0000 (14:13 -0700)
tornado/web.py

index 9c75d7f4a80c4b1946c57bc89d5b422cfa3f0be4..6507d70835b8eaf4c36c85b12dcb499ea9f78b8d 100644 (file)
@@ -1236,6 +1236,8 @@ class StaticFileHandler(RequestHandler):
         self.get(path, include_body=False)
 
     def get(self, path, include_body=True):
+        if os.path.sep != "/":
+            path = path.replace("/", os.path.sep)
         abspath = os.path.abspath(os.path.join(self.root, path))
         # os.path.abspath strips a trailing /
         # it needs to be temporarily added back for requests to root/
@@ -1245,8 +1247,8 @@ class StaticFileHandler(RequestHandler):
             # need to look at the request.path here for when path is empty
             # but there is some prefix to the path that was already
             # trimmed by the routing
-            if not self.request.path.endswith(os.path.sep):
-                self.redirect(self.request.path + os.path.sep)
+            if not self.request.path.endswith("/"):
+                self.redirect(self.request.path + "/")
                 return
             abspath = os.path.join(abspath, self.default_filename)
         if not os.path.exists(abspath):