From: Michael Tremer Date: Thu, 30 May 2019 17:20:18 +0000 (+0100) Subject: wiki: Fix for empty path names X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=76433782ba21934a5b7f3f0f3c4f1b77fe75d938;p=ipfire.org.git wiki: Fix for empty path names path can be None (for empty strings). That is translated to the index page. Signed-off-by: Michael Tremer --- diff --git a/src/web/wiki.py b/src/web/wiki.py index 74a4988e..cfbef8c5 100644 --- a/src/web/wiki.py +++ b/src/web/wiki.py @@ -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))