[patch] addslashes filter doesn't escape backslashes
addslashes filter doesn't escape backslashes. This is important when you want to pass a string that contains backslashes to a JavaScript template.
Here's a patch:
Index: django/template/defaultfilters.py
===================================================================
--- django/template/defaultfilters.py (revision 3496)
+++ django/template/defaultfilters.py (working copy)
@@ -15,7 +15,7 @@
def addslashes(value):
"Adds slashes - useful for passing strings to JavaScript, for example."
- return value.replace('"', '\\"').replace("'", "\\'")
+ return value.replace('\\', '\\\\').replace('"', '\\"').replace("'", "\\'")
def capfirst(value):
"Capitalizes the first character of the value"
Change History
(4)
Component: |
Admin interface → Template system
|
Summary: |
addslashes filter doesn't escape backslashes → [patch] addslashes filter doesn't escape backslashes
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
Does nobody want to fix this bug, which is a major bug IMHO? It's very easy to fix it.