wiki: Fix link handling
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 May 2019 13:36:02 +0000 (14:36 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 May 2019 13:36:02 +0000 (14:36 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/wiki.py

index e3275c2..bc779fd 100644 (file)
@@ -500,10 +500,19 @@ class WikiRenderer(misc.Object):
        def _render_wiki_link(self, m):
                path, alias = m.groups()
 
-               # Allow relative links
-               if not path.startswith("/"):
+               # Nothing to do for absolute links
+               if path.startswith("/"):
+                       pass
+
+               # Relative links (one-level down)
+               elif path.startswith("./"):
                        path = os.path.join(self.path, path)
 
+               # All other relative links
+               else:
+                       p = os.path.dirname(self.path)
+                       path = os.path.join(p, path)
+
                # Normalise links
                path = os.path.normpath(path)