aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_websocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/m_websocket.cpp')
-rw-r--r--src/modules/m_websocket.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/modules/m_websocket.cpp b/src/modules/m_websocket.cpp
index fc3319b4d..2fe41140e 100644
--- a/src/modules/m_websocket.cpp
+++ b/src/modules/m_websocket.cpp
@@ -25,7 +25,8 @@
#include "iohook.h"
#include "modules/hash.h"
-#include <utf8.h>
+#define UTF_CPP_CPLUSPLUS 199711L
+#include <unchecked.h>
static const char MagicGUID[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
static const char whitespace[] = " \t\r\n";
@@ -339,6 +340,11 @@ class WebSocketHook : public IOHookMiddle
}
}
}
+ else
+ {
+ FailHandshake(sock, "HTTP/1.1 400 Bad Request\r\nConnection: close\r\n\r\n", "WebSocket: Received HTTP request that did not send the Origin header");
+ return -1;
+ }
if (!allowedorigin)
{
@@ -437,7 +443,7 @@ class WebSocketHook : public IOHookMiddle
{
// If we send messages as text then we need to ensure they are valid UTF-8.
std::string encoded;
- utf8::replace_invalid(message.begin(), message.end(), std::back_inserter(encoded));
+ utf8::unchecked::replace_invalid(message.begin(), message.end(), std::back_inserter(encoded));
mysendq.push_back(PrepareSendQElem(encoded.length(), OP_TEXT));
mysendq.push_back(encoded);