# HG changeset patch # User Kim Alvefur # Date 1547579310 -3600 # Node ID 7fa273f8869e3b33437f3270f005cad30d5c5e45 # Parent 4c91afc43639e7eb34dff7ddbf399b5d7be36a42 mod_c2s, mod_s2s, mod_component: Log invalid XML escaped (fixes #734) See 6ed0d6224d64 diff -r 4c91afc43639 -r 7fa273f8869e plugins/mod_c2s.lua --- a/plugins/mod_c2s.lua Mon Jan 14 00:17:02 2019 +0100 +++ b/plugins/mod_c2s.lua Tue Jan 15 20:08:30 2019 +0100 @@ -290,7 +290,7 @@ if data then local ok, err = stream:feed(data); if not ok then - log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_")); + log("debug", "Received invalid XML (%s) %d bytes: %q", tostring(err), #data, data:sub(1, 300)); session:close("not-well-formed"); end end diff -r 4c91afc43639 -r 7fa273f8869e plugins/mod_component.lua --- a/plugins/mod_component.lua Mon Jan 14 00:17:02 2019 +0100 +++ b/plugins/mod_component.lua Tue Jan 15 20:08:30 2019 +0100 @@ -310,7 +310,7 @@ function session.data(_, data) local ok, err = stream:feed(data); if ok then return; end - module:log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_")); + log("debug", "Received invalid XML (%s) %d bytes: %q", tostring(err), #data, data:sub(1, 300)); session:close("not-well-formed"); end diff -r 4c91afc43639 -r 7fa273f8869e plugins/mod_s2s/mod_s2s.lua --- a/plugins/mod_s2s/mod_s2s.lua Mon Jan 14 00:17:02 2019 +0100 +++ b/plugins/mod_s2s/mod_s2s.lua Tue Jan 15 20:08:30 2019 +0100 @@ -595,8 +595,7 @@ if data then local ok, err = stream:feed(data); if ok then return; end - log("warn", "Received invalid XML: %s", data); - log("warn", "Problem was: %s", err); + log("debug", "Received invalid XML (%s) %d bytes: %q", tostring(err), #data, data:sub(1, 300)); session:close("not-well-formed"); end end