From f6b061c7a5d0a909e0081931b89addf67538760b Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 17 Aug 2017 10:50:51 -0400 Subject: [PATCH] Improve ability to discriminate between django and mako template Django-format comments are now used to detect a django template. Note: Django templates are still not linted. --- scripts/tests/test_xss_linter.py | 1 + scripts/xss_linter.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/tests/test_xss_linter.py b/scripts/tests/test_xss_linter.py index 1f32f8ef65..2bfdd5e65b 100644 --- a/scripts/tests/test_xss_linter.py +++ b/scripts/tests/test_xss_linter.py @@ -578,6 +578,7 @@ class TestMakoTemplateLinter(TestLinter): @data( {'template': '{% extends "wiki/base.html" %}'}, {'template': '{{ message }}'}, + {'template': '{# comment #}'}, ) def test_check_mako_on_django_template(self, data): """ diff --git a/scripts/xss_linter.py b/scripts/xss_linter.py index 17e5cf240f..42d071d971 100755 --- a/scripts/xss_linter.py +++ b/scripts/xss_linter.py @@ -2003,7 +2003,7 @@ class MakoTemplateLinter(BaseLinter): True if this is really a Django template, and False otherwise. """ - if re.search('({%.*%})|({{.*}})', mako_template) is not None: + if re.search('({%.*%})|({{.*}})|({#.*#})', mako_template) is not None: return True return False