Skip to content

Commit 6bc3f72

Browse files
committed
strengthen /nf/markdown_syntax test, also avoid errors showing up on that page in dev mode
1 parent 3a6df67 commit 6bc3f72

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

Allura/allura/lib/markdown_extensions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from urllib.parse import urljoin
2626

2727
from tg import config
28+
from tg import tmpl_context as c
2829
from bs4 import BeautifulSoup, MarkupResemblesLocatorWarning
2930
import html5lib
3031
import html5lib.serializer
@@ -383,7 +384,7 @@ def handleMatch(self, m: re.Match[str], data: str) -> tuple[etree.Element | None
383384
if href:
384385
if href == 'TOC':
385386
return None, None, None
386-
if self.artifact_re.match(href):
387+
if self.artifact_re.match(href) and c.project:
387388
href, classes = self._expand_alink(href, is_link_with_brackets)
388389
el.set('href', self.unescape(href.strip()))
389390
el.set('class', classes)

Allura/allura/tests/functional/test_newforge.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def test_markdown_syntax(self):
4848
r = self.app.get('/nf/markdown_syntax')
4949
r.mustcontain('Markdown Syntax')
5050
r.mustcontain('href="http://someurl"')
51+
r.mustcontain(no='ERROR')
5152

5253
markdown_invalid_classes = [log[2] for log in logs if 'invalid class' in log[2]]
5354
assert not markdown_invalid_classes
@@ -56,3 +57,4 @@ def test_markdown_syntax_dialog(self):
5657
r = self.app.get('/nf/markdown_syntax_dialog')
5758
r.mustcontain('<h1>Markdown Syntax Guide</h1>')
5859
r.mustcontain('href="http://someurl"')
60+
r.mustcontain(no='ERROR')

0 commit comments

Comments
 (0)