aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-07-11 11:57:42 +0100
committerMatthew Wild <mwild1@gmail.com>2018-07-11 11:57:42 +0100
commit6fbe81217bbdd0f2c0019163f9f0d64cce40b953 (patch)
treeef54536853a0b8a93b9a17cada75c3ba768e2528
parent9aaa5d3ed1e1854c1a02016d8ec22fbbef5a066b (diff)
downloadprosody-6fbe81217bbdd0f2c0019163f9f0d64cce40b953.tar.gz
prosody-6fbe81217bbdd0f2c0019163f9f0d64cce40b953.zip
util.xmppstream: Perfom validation of XML declaration parameters
-rw-r--r--util/xmppstream.lua23
1 files changed, 13 insertions, 10 deletions
diff --git a/util/xmppstream.lua b/util/xmppstream.lua
index 8c7851a5..f245afbf 100644
--- a/util/xmppstream.lua
+++ b/util/xmppstream.lua
@@ -130,16 +130,7 @@ local function new_sax_handlers(session, stream_callbacks, cb_handleprogress)
t_insert(oldstanza.tags, stanza);
end
end
- if lxp_supports_xmldecl then
- function xml_handlers:XmlDecl(version, encoding, standalone)
- session.xml_version = version;
- session.xml_encoding = encoding;
- session.xml_standalone = standalone;
- if lxp_supports_bytecount then
- cb_handleprogress(self:getcurrentbytecount());
- end
- end
- end
+
function xml_handlers:StartCdataSection()
if lxp_supports_bytecount then
if stanza then
@@ -210,6 +201,18 @@ local function new_sax_handlers(session, stream_callbacks, cb_handleprogress)
end
end
+ if lxp_supports_xmldecl then
+ function xml_handlers:XmlDecl(version, encoding, standalone)
+ if lxp_supports_bytecount then
+ cb_handleprogress(self:getcurrentbytecount());
+ end
+ if (encoding and encoding:lower() ~= "utf-8")
+ or (standalone == "no")
+ or (version and version ~= "1.0") then
+ return restricted_handler(self);
+ end
+ end
+ end
if lxp_supports_doctype then
xml_handlers.StartDoctypeDecl = restricted_handler;
end