Malcolm Tredinnick wrote:
> Hey Gary,
> 
> On Tue, 2008-01-08 at 00:35 -0600, Gary Wilson Jr. wrote:
> [...]
>> So, looking at a couple places in Django trunk where response.content is 
>> used,
>> these look like bugs:
>>
>>
>> django.contrib.csrf.middleware.CsrfMiddleware.process_response:
>>
>> def process_response(self, request, response):
>>     ...
>>     response.content = _POST_FORM_RE.sub(add_csrf_field, response.content)
>>     ...
> 
> This isn't a bug, but it's subtle. There is only a problem if you are
> trying to substitute a Python unicode object into a bytestring. That's
> because Python tries to coerce the two elements into the same type
> (unicode in this case) and it uses the "ascii" codec by default. If you
> try to substitute a bytestring into a bytestring, no problems.

I was thinking that two differently-encoded bytestrings could cause problems,
unless...  Are _all_ the valid HTTP character encodings supersets of ascii?

I guess rot13 doesn't count :)

>>> re.compile('sha').sub('not fun', u'fun'.encode('rot13'))
'not fun'


> If you want to be a really good maintainer here and really give encoding
> in responses a workover, these are the things I would think about:

I'll take a look into this when I get some spare time.

Gary

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to