Opened 8 years ago

Closed 8 years ago

Last modified 5 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: UI/UX:

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 Changed 8 years ago by Jacob

milestone: 1.1
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by Keith Bussell

Owner: changed from nobody to Keith Bussell
Status: newassigned

comment:3 Changed 8 years ago by Keith Bussell

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 Changed 8 years ago by Keith Bussell

Cc: kbussell@… added

comment:5 Changed 8 years ago by 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.

comment:6 in reply to:  5 Changed 8 years ago by Keith Bussell

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 Changed 5 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

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