diff --git a/pelican/contents.py b/pelican/contents.py index 3187f328..3d1128c9 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -219,8 +219,8 @@ class Content(object): instrasite_link_regex = self.settings['INTRASITE_LINK_REGEX'] regex = r""" - (?P<\s*[^\>]* # match tag with all url-value attributes - (?:href|src|poster|data|cite|formaction|action)\s*=) + (?P<[^\>]+ # match tag with all url-value attributes + (?:href|src|poster|data|cite|formaction|action)\s*=\s*) (?P["\']) # require value to be quoted (?P{0}(?P.*?)) # the url value diff --git a/pelican/tests/test_contents.py b/pelican/tests/test_contents.py index b4146150..11fa958a 100644 --- a/pelican/tests/test_contents.py +++ b/pelican/tests/test_contents.py @@ -771,3 +771,24 @@ class TestStatic(LoggedTestCase): count=1, msg="Unable to find 'foo', skipping url replacement.", level=logging.WARNING) + + def test_index_link_syntax_with_spaces(self): + """{index} link syntax triggers url replacement + with spaces around the equal sign.""" + + html = 'link' + page = Page( + content=html, + metadata={'title': 'fakepage'}, + settings=self.settings, + source_path=os.path.join('dir', 'otherdir', 'fakepage.md'), + context=self.context) + content = page.get_content('') + + self.assertNotEqual(content, html) + + expected_html = ('link') + self.assertEqual(content, expected_html)