I'm experiencing what I would consider somewhat strange behavior. Specifically if I have a string like this:
1984: Curriculum Unit
by Donald R. Hogue, Center for Learning, George Orwell
"A center for learning publication"--Cover.
It results in the following after being auto-escaped by the Django template system:
1984: Curriculum Unit
by Donald R. Hogue, Center for Learning, George Orwell
"A center for learning publication"--Cover.
The problem seems to be that the " (quote), which should become "
is being escaped twice, resulting in &"
. This results in strange looking formatting. I'm using Django 1.0.2, so it should be up to date, (though I should note I'm using the Ubuntu 9.04 included package python-django) but this behavior seems contrary to the intended behavior.
I've looked a little at django.utils.html.py which includes the actual function:
def escape(html):
"""Returns the given HTML with ampersands, quotes and carets encoded."""
return mark_safe(force_unicode(html).replace('&','&').replace('<','<').replace('>', '>').replace('"', '"').replace("'",'''))
escape = allow_lazy(escape, unicode)
Anyway, that looks like it should escape the & before anything else, which would be fine. So my suspicion is that it is being called twice. Any thoughts?
Thanks.
Update: I was suspicious that it might have something to do with Ubuntu's Django, which it lists as "1.0.2-1" so I installed "1.0.2-final" and am experiencing the same problem.