Commits

Robert Brewer committed 05affd1

Fix for #569 (Encoding problems when accessing cherrypy instances from links).

  • Participants
  • Parent commits 0cafdb3

Comments (0)

Files changed (2)

File cherrypy/lib/encoding.py

         for chunk in cherrypy.response.body:
             body.append(chunk.encode(encoding, errors))
         cherrypy.response.body = body
-    except UnicodeError:
+    except (LookupError, UnicodeError):
         return False
     else:
         return True

File cherrypy/test/test_decodingencoding.py

         self.assertInBody("Your client sent this Accept-Charset header: "
                           "iso-8859-1, *;q=0. We tried these charsets: "
                           "iso-8859-1.")
-
+        
+        # Ask for x-mac-ce, which should be unknown. See ticket #569.
+        self.getPage('/mao_zedong', [('Accept-Charset',
+                                      'us-ascii, ISO-8859-1, x-mac-ce')])
+        self.assertStatus("406 Not Acceptable")
+        self.assertInBody("Your client sent this Accept-Charset header: "
+                          "us-ascii, ISO-8859-1, x-mac-ce. We tried these "
+                          "charsets: x-mac-ce, us-ascii, ISO-8859-1.")
+        
 
 if __name__ == "__main__":
     setup_server()