Permalink
Browse files

Fixes issue where Markdown extension crashes when an absolute URL is …

…used in a wiki link
  • Loading branch information...
benwah committed Apr 15, 2017
1 parent 977eca8 commit bb379e4a76e2e150a62d62bf6261f2e7a808b1d9
Showing with 28 additions and 4 deletions.
  1. +1 −1 requirements_readthedocs.txt
  2. +1 −1 setup.py
  3. +1 −2 wiki/plugins/links/mdx/djangowikilinks.py
  4. +25 −0 wiki/tests/test_markdown_plugins.py
@@ -1,7 +1,7 @@
# This is because readthedocs has an old version of pip
# that somehow doesn't like prerelease versions in the
# dependency expressions (>=1.0b1 failes to find dist)
-Django>=1.8
+Django>=1.8,<1.11
Pillow
django-nyt>=1.0b1
six
View
@@ -27,7 +27,7 @@ def read_file(fname):
requirements = [
- "Django>=1.8",
+ "Django>=1.8,<1.11",
"bleach>=1.5,<2",
"Pillow",
"django-nyt>=1.0b1",
@@ -51,7 +51,6 @@ def __init__(self, configs):
# Override defaults with user settings
for key, value in configs:
- # self.config[key][0] = value
self.setConfig(key, value)
def extendMarkdown(self, md, md_globals):
@@ -84,7 +83,7 @@ def handleMatch(self, m):
if absolute:
base_path = self.config['base_url'][0]
- path_from_link = os_path.join(base_path, article_title)
+ path_from_link = os_path.join(str(base_path), article_title)
urlpath = None
path = path_from_link
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import absolute_import, unicode_literals
+
+import markdown
+from django.test import TestCase
+from django.core.urlresolvers import reverse_lazy
+from wiki.plugins.links.mdx.djangowikilinks import WikiPathExtension
+from wiki.models import URLPath
+
+
+class WikiPathExtensionTests(TestCase):
+ def test_works_with_lazy_functions(self):
+ URLPath.create_root()
+ config = (
+ ('base_url', reverse_lazy('wiki:get', kwargs={'path': ''})),
+ )
+ md = markdown.Markdown(
+ extensions=['extra', WikiPathExtension(config)]
+ )
+ text = '[Français](wiki:/fr)'
+ self.assertEqual(
+ md.convert(text),
+ '<p><a class="wikipath linknotfound" href="/fr">Français</a></p>',
+ )

0 comments on commit bb379e4

Please sign in to comment.