# HG changeset patch # User Matthew Wild # Date 1531306662 -3600 # Node ID 19e51d8f8947b9bec4a729bbbbbc6276fc1b6f0d # Parent d780c10709c10127d76678be48c78c7db9140239 util.xmppstream: Perfom validation of XML declaration parameters diff -r d780c10709c1 -r 19e51d8f8947 util/xmppstream.lua --- 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