Skip to content

WebSockets: allow null characters in text messages data

Carlos Garcia Campos requested to merge carlosgc/websockets-null-char into master

RFC 6455 says that text messages should contains valid UTF-8, and null characters valid according to RFC 3629. However, we are using g_utf8_validate(), which considers null characters as errors, to validate WebSockets text messages. This patch adds an internal utf8_validate() function based on g_utf8_validate() but allowing null characters and just returning a gboolean since we are always ignoring the end parameter in case of errors. soup_websocket_connection_send_text() assumes the given text is null terminated, so we need a new public function to allow sending text messages containing null characters. This patch adds soup_websocket_connection_send_message() that receives a SoupWebsocketDataType and GBytes, which is consistent with SoupWebsocketConnection::message signal.

Merge request reports