Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#13114 closed (fixed)

escapejs filter produces invalid JSON according to http://www.json.org/

Reported by: David Danier <david.danier@…> 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 Russell Keith-Magee, 14 years ago

milestone: 1.2
Triage Stage: UnreviewedAccepted

comment:2 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

(In [12780]) Fixed #13114 -- Modified escapejs to produce output that is JSON compliant. Thanks to David Danier for the report.

comment:3 by Russell Keith-Magee, 14 years ago

(In [12781]) [1.1.X] Fixed #13114 -- Modified escapejs to produce output that is JSON compliant. Thanks to David Danier for the report.

Backport of r12780 from trunk.

comment:4 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top