Opened 15 years ago

Closed 15 years ago

Last modified 12 years ago

#9580 closed (wontfix)

javascript_quote should accept SafeUnicode

Reported by: boyerchen@… Owned by: Keith Bussell
Component: Uncategorized Version: 1.0-beta
Severity: Keywords:
Cc: kbussell@… Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

django.utils.javascript_quote does not accept a SafeUnicode instance as argument and raises a TypeError.

Expected behavior:
Treat SafeUnicode as usual unicode string.

Change History (7)

comment:1 by Jacob, 15 years ago

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:2 by Keith Bussell, 15 years ago

Owner: changed from nobody to Keith Bussell
Status: newassigned

comment:3 by Keith Bussell, 15 years ago

Triage Stage: AcceptedDesign decision needed

django.utils is for tools internal to Django, and nothing at this layer currently knows about safe strings.

How are you using this function? Note: If you're calling this from a template, you can use django.template.defaultfilters.escapejs.

comment:4 by Keith Bussell, 15 years ago

Cc: kbussell@… added

comment:5 by Passy, 15 years ago

I used it to escape a rendered form in an ajax response to load it afterwards into a wrapper element with javascript. I currently decode it as UTF-8, but I guess supporting a safe string would be more intuitive.

in reply to:  5 comment:6 by Keith Bussell, 15 years ago

Resolution: wontfix
Status: assignedclosed

Replying to Passy:

I used it to escape a rendered form in an ajax response to load it afterwards into a wrapper element with javascript. I currently decode it as UTF-8, but I guess supporting a safe string would be more intuitive.

Use django.template.defaultfilters.escapejs instead of javascript_quote. (You don't need to limit use of template filters to template rendering. Filters are just functions that operate on strings, and safe strings.)

(resolution approved by Jacob)

comment:7 by Jacob, 12 years ago

milestone: 1.1

Milestone 1.1 deleted

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