Bug 764661 pt 1 - ensure middleware returns string, not unicode; r=rfkelly
authorRob Miller <rmiller@mozilla.com>
Tue, 23 Oct 2012 09:14:32 +1100
changeset 241 fee9281853e590c2c4acab1097f32ca2d3ad5508
parent 240 ad01f9c7479d458572d8d93e33038575e8cd159d
child 242 a08c5268c96223c3fcc61bd2c89880c325b39d92
push id167
push userrkelly@mozilla.com
push dateMon, 22 Oct 2012 22:16:58 +0000
reviewersrfkelly
bugs764661
Bug 764661 pt 1 - ensure middleware returns string, not unicode; r=rfkelly
keyexchange/filtering/middleware.py
--- a/keyexchange/filtering/middleware.py
+++ b/keyexchange/filtering/middleware.py
@@ -202,19 +202,22 @@ class IPFiltering(object):
                 if ip in self._last_br_ips:
                     self._last_br_ips.remove(ip)
             except KeyError:
                 pass
 
         headers = [('Content-Type', 'text/html')]
         start_response('200 OK', headers)
         # we want to display the list of blacklisted IPs
-        return [self._admin_tpl.render(ips=self._blacklisted.ips,
-                                       admin_page=self.admin_page,
-                                       observe=self.observe)]
+        output = self._admin_tpl.render(ips=self._blacklisted.ips,
+                                        admin_page=self.admin_page,
+                                        observe=self.observe)
+        if isinstance(output, unicode):
+            output = output.encode('utf-8')
+        return [output]
 
     def __call__(self, environ, start_response):
         # is it an admin call ?
         url = environ.get('PATH_INFO')
         if url is not None and url == self.admin_page:
             return self.admin(environ, start_response)
 
         start_response_status = []