Escape performable tags

See this entry[1] in the django 1.9 release notes for details.

[1]: https://docs.djangoproject.com/en/1.9/releases/1.9/#simple-tag-now-wraps-tag-output-in-conditional-escape
This commit is contained in:
Hugo Osvaldo Barrera 2015-12-06 12:21:52 -03:00
parent b833f37f95
commit d42e6d348b
2 changed files with 8 additions and 6 deletions

View file

@ -7,6 +7,7 @@ from __future__ import absolute_import
import re
from django.template import Library, Node, TemplateSyntaxError
from django.utils.safestring import mark_safe
from analytical.utils import is_internal_ip, disable_html, get_identity, \
get_required_setting
@ -71,7 +72,7 @@ def performable_embed(hostname, page_id):
"""
Include a Performable landing page.
"""
return EMBED_CODE % {'hostname': hostname, 'page_id': page_id}
return mark_safe(EMBED_CODE % {'hostname': hostname, 'page_id': page_id})
def contribute_to_analytical(add_node):

View file

@ -63,8 +63,9 @@ class PerformableEmbedTagTestCase(TagTestCase):
def test_tag(self):
domain = 'example.com'
page = 'test'
r = self.render_tag('performable', 'performable_embed "%s" "%s"'
% (domain, page))
self.assertTrue(
"$f.initialize({'host': 'example.com', 'page': 'test'});" in r,
r)
tag = self.render_tag(
'performable', 'performable_embed "%s" "%s"' % (domain, page)
)
self.assertIn(
"$f.initialize({'host': 'example.com', 'page': 'test'});", tag
)