Changeset

9020:19e51d8f8947

util.xmppstream: Perfom validation of XML declaration parameters
author Matthew Wild <mwild1@gmail.com>
date Wed, 11 Jul 2018 11:57:42 +0100
parents 9019:d780c10709c1
children 9021:548ba4090012
files util/xmppstream.lua
diffstat 1 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/util/xmppstream.lua	Wed Jul 11 12:05:06 2018 +0200
+++ b/util/xmppstream.lua	Wed Jul 11 11:57:42 2018 +0100
@@ -130,16 +130,7 @@
 			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 @@
 		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