2009-11-25 Yuzo Fujishima <yuzo@google.com>
[WebKit-https.git] / WebKitTools / pywebsocket / mod_pywebsocket / msgutil.py
index bdb554de85240b4e1111ff47e6465514adc54966..9fa9b59a5c9e2ea49c1af7cc3e60d27a33cc29c4 100644 (file)
@@ -73,7 +73,9 @@ def receive_message(request):
         else:
             # The payload is delimited with \xff.
             bytes = _read_until(request, '\xff')
-            message = bytes.decode('utf-8')
+            # The Web Socket protocol section 4.4 specifies that invalid
+            # characters must be replaced with U+fffd REPLACEMENT CHARACTER.
+            message = bytes.decode('utf-8', 'replace')
             if frame_type == 0x00:
                 return message
             # Discard data of other types.