]> git.ipfire.org Git - ipfire.org.git/commitdiff
wiki: Fix for empty path names
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 May 2019 17:20:18 +0000 (18:20 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 May 2019 17:20:18 +0000 (18:20 +0100)
path can be None (for empty strings). That is translated to the index page.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/web/wiki.py

index 74a4988e9aee17670281dd6fea474be908ea03d2..cfbef8c54766524ba72dbb92e324256e58505160 100644 (file)
@@ -10,6 +10,9 @@ from . import ui_modules
 class ActionEditHandler(auth.CacheMixin, base.BaseHandler):
        @tornado.web.authenticated
        def get(self, path):
+               if path is None:
+                       path = "/"
+
                # Check permissions
                if not self.backend.wiki.check_acl(path, self.current_user):
                        raise tornado.web.HTTPError(403, "Access to %s not allowed for %s" % (path, self.current_user))
@@ -26,6 +29,9 @@ class ActionEditHandler(auth.CacheMixin, base.BaseHandler):
 
        @tornado.web.authenticated
        def post(self, path):
+               if path is None:
+                       path = "/"
+
                # Check permissions
                if not self.backend.wiki.check_acl(path, self.current_user):
                        raise tornado.web.HTTPError(403, "Access to %s not allowed for %s" % (path, self.current_user))
@@ -87,6 +93,9 @@ class ActionUploadHandler(auth.CacheMixin, base.BaseHandler):
 class ActionWatchHandler(auth.CacheMixin, base.BaseHandler):
        @tornado.web.authenticated
        def get(self, path, action):
+               if path is None:
+                       path = "/"
+
                page = self.backend.wiki.get_page(path)
                if not page:
                        raise tornado.web.HTTPError(404, "Page does not exist: %s" % path)
@@ -111,6 +120,9 @@ class ActionRenderHandler(auth.CacheMixin, base.BaseHandler):
 
        @tornado.web.authenticated
        def post(self, path):
+               if path is None:
+                       path = "/"
+
                content = self.get_argument("content")
 
                # Render the content
@@ -122,6 +134,9 @@ class ActionRenderHandler(auth.CacheMixin, base.BaseHandler):
 class FilesHandler(auth.CacheMixin, base.BaseHandler):
        @tornado.web.authenticated
        def get(self, path):
+               if path is None:
+                       path = "/"
+
                # Check permissions
                if not self.backend.wiki.check_acl(path, self.current_user):
                        raise tornado.web.HTTPError(403, "Access to %s not allowed for %s" % (path, self.current_user))
@@ -193,6 +208,9 @@ class PageHandler(auth.CacheMixin, base.BaseHandler):
 
        @tornado.web.removeslash
        def get(self, path):
+               if path is None:
+                       path = "/"
+
                # Check permissions
                if not self.backend.wiki.check_acl(path, self.current_user):
                        raise tornado.web.HTTPError(403, "Access to %s not allowed for %s" % (path, self.current_user))