Actually use the safer (escaped) string we construct

Also, no reason to append a null byte to it.

Don't know why this worked even when not escaping "dangerous"
characters. Does Webkit have a more relaxed lexical analyser?

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Idfedcbf11a9ee565b954ba972e7e3bc9b804a122
pull/5646/head
Tor Lillqvist 2023-01-04 12:59:34 +02:00 committed by Tor Lillqvist
parent 383b6a7080
commit 410270fd14
1 changed files with 2 additions and 3 deletions

View File

@ -30,7 +30,7 @@
const char *user_name = "Dummy";
const int SHOW_JS_MAXLEN = 70;
const int SHOW_JS_MAXLEN = 300;
int coolwsd_server_socket_fd = -1;
@ -87,10 +87,9 @@ static void send2JS(const std::vector<char>& buffer)
data.push_back(ubufp[i]);
}
}
data.push_back(0);
js = "window.TheFakeWebSocket.onmessage({'data': '";
js = js + std::string(buffer.data(), buffer.size());
js = js + std::string(data.data(), data.size());
js = js + "'});";
}