From cffb896bb194b0fb64aa6f84f7bb1fef43ceb17b Mon Sep 17 00:00:00 2001 From: Alice Date: Fri, 2 Jan 2015 00:27:29 -0500 Subject: [PATCH] Bug 1116419: Highlight 'bug' ignoring case in Wiki comments and history --- kuma/wiki/helpers.py | 9 +++++---- kuma/wiki/tests/test_content.py | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/kuma/wiki/helpers.py b/kuma/wiki/helpers.py index bfee761de68..fe9014c9239 100644 --- a/kuma/wiki/helpers.py +++ b/kuma/wiki/helpers.py @@ -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('bug \\1'), + regex = re.compile('(bug)\s+#?(\d+)', re.IGNORECASE) + content = regex.sub( + jinja2.Markup('\\1 \\2'), content) return content diff --git a/kuma/wiki/tests/test_content.py b/kuma/wiki/tests/test_content.py index 06ec916a30a..7ac1c1c0f1d 100644 --- a/kuma/wiki/tests/test_content.py +++ b/kuma/wiki/tests/test_content.py @@ -739,6 +739,10 @@ def test_bugize_text(self): good = 'Fixing bug 12345 again. <img src="http://davidwalsh.name" /> <a href="">javascript></a>' eq_(bugize_text(bad), Markup(good)) + bad_upper = 'Fixing Bug #12345 again.' + good_upper = 'Fixing Bug 12345 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