[ZCM] [ZC] 2280/ 3 Comment "getPreferredCharsets() returns iso-8859-1 and not utf-8 when HTTP_ACCEPT_CHARSET not present in request"
"Collector: Zope Bugs, Features, and Patches ..." <[email protected]> Fri, 16 Feb 2007 11:52:06 -0500
| Newsgroups | gmane.comp.web.zope.devel.collector-monitor |
|---|---|
| Message-ID | <[email protected]> |
Issue #2280 Update (Comment) "getPreferredCharsets() returns iso-8859-1 and not utf-8 when HTTP_ACCEPT_CHARSET not present in request"
Status Rejected, Zope/bug+solution medium
To followup, visit:
http://www.zope.org/Collectors/Zope/2280
==============================================================
= Comment - Entry #3 by philikon on Feb 16, 2007 11:52 am
This might be a problem local to Zope 2, or it may not be a problem at all at this point. Hard to say. Point is:
* str(self.request) is not really a solution. In fact, it's pretty weird and wrong.
* type(self.request) returning <type 'instance'> is normal.
* sys.setdefaultencoding() is evil evil evil. Don't use that.
We need more info to reproduce this issue. Ideally, an HTTP transcript (e.g. using tcpwatch) would be best. Until then the issue remains rejected.
________________________________________
= Reject - Entry #2 by ajung on Feb 16, 2007 11:38 am
Status: Pending => Rejected
This belongs into the Zope 3 bugtracker since it addresses an issues in the Zope 3 core
________________________________________
= Request - Entry #1 by jost on Feb 16, 2007 11:30 am
I'm not sure if I'm sumitting this the right place or if this is just a local problem not affecting any other, but I have the following problem:
While using Internet Explorer 7 (IE7), the method getPreferredCharsets() in the class HTTPCharsets (http.py) returns 'iso-8859-1' and not 'utf-8' as expected. As far as I know, IE7 does not set the HTTP_ACCEPT_CHARSET in the request. Reading the source I would expect that no HTTP_ACCEPT_CHARSET should result in a return value of 'utf-8'.
At least on my system the line 996 of /lib/python/zope/publisher/http.py
header_present = 'HTTP_ACCEPT_CHARSET' in self.request
sets header_present = True, even if self.request does not contain 'HTTP_ACCEPT_CHARSET'!
Suspecting a problem with the line, not understanding why, I changed it to:
header_present = 'HTTP_ACCEPT_CHARSET' in str(self.request)
This resolves my problem.
###################
Other charset related settings I have changed:
Have set sys.setdefaultencoding('utf-8') in /usr/local/lib/python2.4/site.py.
Have set management_page_charset='utf-8' as property of / in ZMI.
Have set default-zpublisher-encoding utf-8 in etc/zope.conf.
Adding for debug in /lib/python/zope/publisher/http.py (around line 1000):
print type(self.request)
returns:
<type 'instance'>
==============================================================