Re: UnicodeDecodeError from PageTemplate rendering after upgrading to Zope 2.12.7

Robert Casties <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
Hi Chris,

On 08/31/2010 11:40 AM, Chris Withers wrote:
> After a recent upgraded to Zope 2.12, I'm now seeing errors like the 
> following when using IE (version 8) or Safari (version 4.0.3) to view 
> page templates. Chrome and Firefox work fine.

This may be related to IE and Safari not sending an accept-charset
header and Zope then falling back to the Python default (often ASCII)
for encoding, which then fails.

I use the following patch to http.py (tested up to 2.12.3):

--- lib/python/zope/publisher/http.py.orig      2009-05-02
00:49:35.000000000 -0700
+++ lib/python/zope/publisher/http.py   2009-06-12 02:12:50.000000000 -0700
@@ -965,8 +965,11 @@
         # value of 1 if not explicitly mentioned.
         # And quoting RFC 2616, $14.2: "If no Accept-Charset header is
         # present, the default is that any character set is acceptable."
-        if not sawstar and not sawiso88591 and header_present:
+        # ROC: the following checked also for header_present which
seemed wrong
+        if not sawstar and not sawiso88591:
             charsets.append((1.0, 'iso-8859-1'))
+            # ROC: if there is no header we assume star (to get utf-8)
+            sawstar = 1
         # UTF-8 is **always** preferred over anything else.
         # Reason: UTF-8 is not specific and can encode the entire unicode
         # range , unlike many other encodings. Since Zope can easily
use very


Best
	Robert


_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.