Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Bug 1116419: Highlight 'bug' ignoring case in Wiki comments and history
Browse files Browse the repository at this point in the history
  • Loading branch information
adusca committed Jan 2, 2015
1 parent ef981f2 commit cffb896
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions kuma/wiki/helpers.py
Expand Up @@ -94,10 +94,11 @@ def _massage_diff_content(content):
@register.filter
def bugize_text(content):
content = jinja2.escape(content)
content = re.sub(r'bug\s+#?(\d+)',
jinja2.Markup('<a href="https://bugzilla.mozilla.org/'
'show_bug.cgi?id=\\1" '
'target="_blank">bug \\1</a>'),
regex = re.compile('(bug)\s+#?(\d+)', re.IGNORECASE)
content = regex.sub(
jinja2.Markup('<a href="https://bugzilla.mozilla.org/'
'show_bug.cgi?id=\\2" '
'target="_blank">\\1 \\2</a>'),
content)
return content

Expand Down
4 changes: 4 additions & 0 deletions kuma/wiki/tests/test_content.py
Expand Up @@ -739,6 +739,10 @@ def test_bugize_text(self):
good = 'Fixing <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=12345" target="_blank">bug 12345</a> again. &lt;img src=&#34;http://davidwalsh.name&#34; /&gt; &lt;a href=&#34;&#34;&gt;javascript&gt;&lt;/a&gt;'
eq_(bugize_text(bad), Markup(good))

bad_upper = 'Fixing Bug #12345 again.'
good_upper = 'Fixing <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=12345" target="_blank">Bug 12345</a> again.'
eq_(bugize_text(bad_upper), Markup(good_upper))

def test_iframe_host_filter(self):
slug = 'test-code-embed'
embed_url = 'https://sampleserver/en-US/docs/%s$samples/sample1' % slug
Expand Down

0 comments on commit cffb896

Please sign in to comment.