summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWichert Akkerman <wichert@wiggy.net>2013-12-10 13:31:23 +0100
committerWichert Akkerman <wichert@wiggy.net>2013-12-10 13:31:23 +0100
commit3c95b1af3661618490e6a3789fd80755924e7d18 (patch)
tree0324d7ac67c7b1b1b8ba7ea1c85d1e59fb43d908
parentc503891d43251e7bf6111c6c1f521b43c55d917b (diff)
downloadpyramid-3c95b1af3661618490e6a3789fd80755924e7d18.tar.gz
pyramid-3c95b1af3661618490e6a3789fd80755924e7d18.tar.bz2
pyramid-3c95b1af3661618490e6a3789fd80755924e7d18.zip
Fix JSONP syntax error
-rw-r--r--CHANGES.txt3
-rw-r--r--pyramid/renderers.py2
-rw-r--r--pyramid/tests/test_renderers.py2
3 files changed, 5 insertions, 2 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 9f780fe45..c05c4561e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -51,6 +51,9 @@ Features
Bug Fixes
---------
+- Add a trailing semicolon to the JSONP response. This fixes JavaScript syntax
+ errors for old IE versions.
+
- Fix the ``pcreate`` script so that when the target directory name ends with a
slash it does not produce a non-working project directory structure.
Previously saying ``pcreate -s starter /foo/bar/`` produced different output
diff --git a/pyramid/renderers.py b/pyramid/renderers.py
index e90d07b38..88ef285a0 100644
--- a/pyramid/renderers.py
+++ b/pyramid/renderers.py
@@ -363,7 +363,7 @@ class JSONP(JSON):
body = val
else:
ct = 'application/javascript'
- body = '%s(%s)' % (callback, val)
+ body = '%s(%s);' % (callback, val)
response = request.response
if response.content_type == response.default_content_type:
response.content_type = ct
diff --git a/pyramid/tests/test_renderers.py b/pyramid/tests/test_renderers.py
index f6b9d2b0d..2bddd2318 100644
--- a/pyramid/tests/test_renderers.py
+++ b/pyramid/tests/test_renderers.py
@@ -567,7 +567,7 @@ class TestJSONP(unittest.TestCase):
request = testing.DummyRequest()
request.GET['callback'] = 'callback'
result = renderer({'a':'1'}, {'request':request})
- self.assertEqual(result, 'callback({"a": "1"})')
+ self.assertEqual(result, 'callback({"a": "1"});')
self.assertEqual(request.response.content_type,
'application/javascript')