Skip to content

Commit

Permalink
Mark as already escape JSFuncCall too and update test to check the re…
Browse files Browse the repository at this point in the history
…sult for all the template engines
  • Loading branch information
amol- committed Aug 28, 2012
1 parent 5e138ac commit 7c0c60a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions tests/test_resources.py
Expand Up @@ -262,8 +262,9 @@ class TestJsFuncall(tb.WidgetTest):
expected = None expected = None


def test_display(self): def test_display(self):
r = self.widget(**self.attrs).display(**self.params) for t in self._get_all_possible_engines():
assert r == """<script type="text/javascript">foo("a", "b")</script>""", r r = self.widget(**self.attrs).display(template='%s:%s' % (t, twr._JSFuncCall.template))
assert r == """<script type="text/javascript">foo("a", "b")</script>""", r


from pkg_resources import Requirement from pkg_resources import Requirement
class TestResourcesApp: class TestResourcesApp:
Expand Down
4 changes: 3 additions & 1 deletion tw2/core/resources.py
Expand Up @@ -16,6 +16,8 @@
import middleware as md import middleware as md
from js import encoder, js_symbol from js import encoder, js_symbol


from markupsafe import Markup

log = logging.getLogger(__name__) log = logging.getLogger(__name__)




Expand Down Expand Up @@ -275,7 +277,7 @@ def prepare(self):
elif self.args: elif self.args:
args = ', '.join(encoder.encode(a) for a in self.args) args = ', '.join(encoder.encode(a) for a in self.args)


self.src = '%s(%s)' % (self.function, args) self.src = Markup('%s(%s)' % (self.function, args))
super(_JSFuncCall, self).prepare() super(_JSFuncCall, self).prepare()


def __hash__(self): def __hash__(self):
Expand Down

0 comments on commit 7c0c60a

Please sign in to comment.