"id": str(uuid.uuid4()),
"body": parsed["body"],
}
- chat["html"] = self.render_string("message.html", message=chat)
+ chat["html"] = tornado.escape.to_basestring(
+ self.render_string("message.html", message=chat))
ChatSocketHandler.update_cache(chat)
ChatSocketHandler.send_updates(chat)
from tornado.log import gen_log, app_log
from tornado.netutil import Resolver
from tornado import simple_httpclient
-from tornado.util import bytes_type
+from tornado.util import bytes_type, unicode_type
try:
xrange # py2
"""Processes the key headers and calculates their key value.
Raises ValueError when feed invalid key."""
+ # pyflakes complains about variable reuse if both of these lines use 'c'
number = int(''.join(c for c in key if c.isdigit()))
- spaces = len(c for c in key if c.isspace())
+ spaces = len([c2 for c2 in key if c2.isspace()])
try:
key_number = number // spaces
except (ValueError, ZeroDivisionError):
if binary:
raise ValueError(
"Binary messages not supported by this version of websockets")
- if isinstance(message, unicode):
+ if isinstance(message, unicode_type):
message = message.encode("utf-8")
assert isinstance(message, bytes_type)
self.stream.write(b"\x00" + message + b"\xff")