#9580 closed (wontfix)
javascript_quote should accept SafeUnicode
Reported by: | 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 , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 16 years ago
Triage Stage: | Accepted → Design decision needed |
---|
comment:4 by , 16 years ago
Cc: | added |
---|
follow-up: 6 comment:5 by , 16 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.
comment:6 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
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)
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
.