diff --git a/DOCKER_VERSION b/DOCKER_VERSION index cdb98d26..76e9e619 100644 --- a/DOCKER_VERSION +++ b/DOCKER_VERSION @@ -1 +1 @@ -5.1.3 +5.1.4 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c6ed6234..288f05c5 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. +## [5.1.4] - 2019-09-03 + +Sending invalid UTF-8 TEXT message should fail and close the connection (fix **tons** of autobahn test: 6.X UTF-8 Handling) + ## [5.1.3] - 2019-09-03 Message type (TEXT or BINARY) is invalid for received fragmented messages (fix autobahn test: 5.3 through 5.8 Fragmentation) diff --git a/ixwebsocket/IXWebSocket.cpp b/ixwebsocket/IXWebSocket.cpp index 9fc7fe55..b94af0b9 100644 --- a/ixwebsocket/IXWebSocket.cpp +++ b/ixwebsocket/IXWebSocket.cpp @@ -447,9 +447,7 @@ namespace ix bool binary, const OnProgressCallback& onProgressCallback) { - return sendMessage(data, - (binary) ? SendMessageKind::Binary: SendMessageKind::Text, - onProgressCallback); + return (binary) ? sendBinary(data, onProgressCallback) : sendText(data, onProgressCallback); } WebSocketSendInfo WebSocket::sendBinary(const std::string& text, @@ -463,7 +461,8 @@ namespace ix { if (!isValidUtf8(text)) { - stop(); + close(WebSocketCloseConstants::kNormalClosureCode, + WebSocketCloseConstants::kInvalidUtf8); return false; } return sendMessage(text, SendMessageKind::Text, onProgressCallback); diff --git a/ixwebsocket/IXWebSocketCloseConstants.cpp b/ixwebsocket/IXWebSocketCloseConstants.cpp index ff80bea6..deb0704a 100644 --- a/ixwebsocket/IXWebSocketCloseConstants.cpp +++ b/ixwebsocket/IXWebSocketCloseConstants.cpp @@ -23,4 +23,5 @@ namespace ix const std::string WebSocketCloseConstants::kProtocolErrorReservedBitUsed("Reserved bit used"); const std::string WebSocketCloseConstants::kProtocolErrorPingPayloadOversized("Ping reason control frame with payload length > 125 octets"); const std::string WebSocketCloseConstants::kProtocolErrorCodeControlMessageFragmented("Control message fragmented"); + const std::string WebSocketCloseConstants::kInvalidUtf8("Invalid UTF-8"); } diff --git a/ixwebsocket/IXWebSocketCloseConstants.h b/ixwebsocket/IXWebSocketCloseConstants.h index e45632fb..fb13b6a0 100644 --- a/ixwebsocket/IXWebSocketCloseConstants.h +++ b/ixwebsocket/IXWebSocketCloseConstants.h @@ -28,5 +28,6 @@ namespace ix static const std::string kProtocolErrorReservedBitUsed; static const std::string kProtocolErrorPingPayloadOversized; static const std::string kProtocolErrorCodeControlMessageFragmented; + static const std::string kInvalidUtf8; }; } // namespace ix diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index a6195514..aff84a3a 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "5.1.3" +#define IX_WEBSOCKET_VERSION "5.1.4"