Diff

mod_pubsub_eventsource/mod_pubsub_eventsource.lua @ 4508:0329cf8cdecb

mod_pubsub_eventsource: Fix processing of newlines
author Kim Alvefur <zash@zash.se>
date Fri, 12 Mar 2021 21:32:03 +0100
parent 1343:7dbde05b48a9
line wrap: on
line diff
--- a/mod_pubsub_eventsource/mod_pubsub_eventsource.lua	Fri Mar 12 11:00:26 2021 +0100
+++ b/mod_pubsub_eventsource/mod_pubsub_eventsource.lua	Fri Mar 12 21:32:03 2021 +0100
@@ -49,7 +49,7 @@
 	if (item.name == "json" and item.attr.xmlns == "urn:xmpp:json:0") or (item.name == "data" and item.attr.xmlns == "https://prosody.im/protocol/data") then
 		item = item[1];
 	end
-	local data = "data: "..tostring(item):gsub("\n", "\ndata: \n").."\n\n";
+	local data = "data: "..tostring(item):gsub("\n", "\ndata: ").."\n\n";
 	if not clientlist then module:log("debug", "No clients for %q", node); return; end
 	for response, conn in pairs(clientlist) do
 		conn:write(data);