diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 60c68198..e49a58c8 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -3,8 +3,9 @@ All notable changes to this project will be documented in this file. ## [5.1.6] - 2019-09-03 -Sending invalid UTF-8 TEXT message should fail and close the connection (fix remaining autobahn test: 6.X UTF-8 Handling) -Fix failing unittest which was sending binary data in text mode with WebSocket::send to call properly call WebSocket::sendBinary instead. +- Sending invalid UTF-8 TEXT message should fail and close the connection (fix remaining autobahn test: 6.X UTF-8 Handling) +- Fix failing unittest which was sending binary data in text mode with WebSocket::send to call properly call WebSocket::sendBinary instead. +- Validate that the reason is proper utf-8. (fix autobahn test 7.5.1) ## [5.1.5] - 2019-09-03 diff --git a/ixwebsocket/IXWebSocketTransport.cpp b/ixwebsocket/IXWebSocketTransport.cpp index 20221cba..d5664dde 100644 --- a/ixwebsocket/IXWebSocketTransport.cpp +++ b/ixwebsocket/IXWebSocketTransport.cpp @@ -37,6 +37,7 @@ #include "IXWebSocketHttpHeaders.h" #include "IXUrlParser.h" #include "IXSocketFactory.h" +#include "IXUtf8Validator.h" #include #include @@ -676,6 +677,13 @@ namespace ix reason.assign(_rxbuf.begin()+ws.header_size + 2, _rxbuf.begin()+ws.header_size + (size_t) ws.N); } + + // Validate that the reason is proper utf-8. Autobahn 7.5.1 + if (!validateUtf8(reason)) + { + code = WebSocketCloseConstants::kInvalidFramePayloadData; + reason = WebSocketCloseConstants::kInvalidFramePayloadDataMessage; + } } else {