changeset 872:f320205ca1f9

Ensure that master only sends utf-8 bodies (especially errors are prone to contain strings of unknown origin, potentially unicode).
author osimons
date Tue, 19 Oct 2010 20:55:13 +0000
parents c837eaf8ff2e
children e695efec5b28
files bitten/master.py
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/master.py
+++ b/bitten/master.py
@@ -143,6 +143,8 @@
 
     def _send_response(self, req, code=200, body='', headers=None):
         """ Formats and sends the response, raising ``RequestDone``. """
+        if isinstance(body, unicode):
+            body = body.encode('utf-8')
         req.send_response(code)
         headers = headers or {}
         headers.setdefault('Content-Length', len(body))
Copyright (C) 2012-2017 Edgewall Software