aboutsummaryrefslogtreecommitdiffstats
path: root/util
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
commit8402f5a2bfc510fdb14e5d4df169cf084f6f2ab9 (patch)
treeef54536853a0b8a93b9a17cada75c3ba768e2528 /util
parent43f84c08dac352ad5a37232a2a5d4459911da680 (diff)
downloadprosody-8402f5a2bfc510fdb14e5d4df169cf084f6f2ab9.tar.gz
prosody-8402f5a2bfc510fdb14e5d4df169cf084f6f2ab9.zip
util.xmppstream: Perfom validation of XML declaration parameters
Diffstat (limited to 'util')
-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