#13114 closed (fixed)
escapejs filter produces invalid JSON according to http://www.json.org/
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Uncategorized | Version: | 1.1 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The escapejs filter uses \x.. to escape special characters inside strings. According to http://www.json.org/ this is wrong, \u.... should be used instead.
This actually bite me while using jQuery. Since jQuery 1.4 the JSON-responses get validated, so all my JSON-responses (that are constructed using escapejs) got broken.
Patch to fix this should be rather trivial.
Steps to reproduce:
>>> from django.template.defaultfilters import escapejs >>> print escapejs('just-a-test') just\x2Da\x2Dtest
Open http://www.jsonlint.com/ and paste ["just\x2Da\x2Dtest"]
, hit Validate.
Change History (4)
comment:1 by , 15 years ago
milestone: | → 1.2 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 15 years ago
Note:
See TracTickets
for help on using tickets.
(In [12780]) Fixed #13114 -- Modified escapejs to produce output that is JSON compliant. Thanks to David Danier for the report.