Comparison

mod_http_xep227/mod_http_xep227.lua @ 4868:57311c545013

mod_http_xep227: Fix validation of resulting export XML
author Matthew Wild <mwild1@gmail.com>
date Sat, 15 Jan 2022 14:06:19 +0000
parent 4867:9d29467f4d5b
child 4869:c3bf568e3977
comparison
equal deleted inserted replaced
4867:9d29467f4d5b 4868:57311c545013
130 module:log("info", "%d items migrated, %d errors", count, errs); 130 module:log("info", "%d items migrated, %d errors", count, errs);
131 end 131 end
132 end 132 end
133 end 133 end
134 134
135 if not user_xml or not user_xml:find("host/user") then 135 local xml_data = user_xml:get_user_xml(username, session.host);
136 module:log("warn", "No data to export: %s", tostring(user_xml)); 136
137 if not xml_data or not xml_data:find("host/user") then
138 module:log("warn", "No data to export: %s", tostring(xml_data));
137 return 204; 139 return 204;
138 end 140 end
139 141
140 event.response.headers["Content-Type"] = "application/xml"; 142 event.response.headers["Content-Type"] = "application/xml";
141 return [[<?xml version="1.0" encoding="utf-8" ?>]]..tostring(user_xml); 143 return [[<?xml version="1.0" encoding="utf-8" ?>]]..tostring(xml_data);
142 end 144 end
143 145
144 local function is_looking_like_xep227(xml_data) 146 local function is_looking_like_xep227(xml_data)
145 if not xml_data or xml_data.name ~= "server-data" 147 if not xml_data or xml_data.name ~= "server-data"
146 or xml_data.attr.xmlns ~= "urn:xmpp:pie:0" then 148 or xml_data.attr.xmlns ~= "urn:xmpp:pie:0" then