Comparison

plugins/mod_storage_xep0227.lua @ 12176:e7639625a848

mod_storage_xep0227: Fix writing non-user data Attempt to concatenate nil 'user' Not much data actually makes sense but the migrator tries to write or clear these.
author Kim Alvefur <zash@zash.se>
date Mon, 10 Jan 2022 16:53:58 +0100
parent 12175:39921b979edb
child 12183:e77c938ed92b
comparison
equal deleted inserted replaced
12175:39921b979edb 12176:e7639625a848
5 local next, unpack = next, table.unpack or unpack; --luacheck: ignore 113/unpack 5 local next, unpack = next, table.unpack or unpack; --luacheck: ignore 113/unpack
6 local os_remove = os.remove; 6 local os_remove = os.remove;
7 local io_open = io.open; 7 local io_open = io.open;
8 local jid_bare = require "util.jid".bare; 8 local jid_bare = require "util.jid".bare;
9 local jid_prep = require "util.jid".prep; 9 local jid_prep = require "util.jid".prep;
10 local jid_join = require "util.jid".join;
10 11
11 local array = require "util.array"; 12 local array = require "util.array";
12 local base64 = require "util.encodings".base64; 13 local base64 = require "util.encodings".base64;
13 local dt = require "util.datetime"; 14 local dt = require "util.datetime";
14 local hex = require "util.hex"; 15 local hex = require "util.hex";
19 local parse_xml_real = require "util.xml".parse; 20 local parse_xml_real = require "util.xml".parse;
20 21
21 local lfs = require "lfs"; 22 local lfs = require "lfs";
22 23
23 local function default_get_user_xml(self, user, host) --luacheck: ignore 212/self 24 local function default_get_user_xml(self, user, host) --luacheck: ignore 212/self
24 local jid = user.."@"..host; 25 local jid = jid_join(user, host);
25 local path = paths.join(prosody.paths.data, jid..".xml"); 26 local path = paths.join(prosody.paths.data, jid..".xml");
26 local f, err = io_open(path); 27 local f, err = io_open(path);
27 if not f then 28 if not f then
28 module:log("debug", "Unable to load XML file for <%s>: %s", jid, err); 29 module:log("debug", "Unable to load XML file for <%s>: %s", jid, err);
29 return; 30 return;
32 local s = f:read("*a"); 33 local s = f:read("*a");
33 f:close(); 34 f:close();
34 return parse_xml_real(s); 35 return parse_xml_real(s);
35 end 36 end
36 local function default_set_user_xml(user, host, xml) 37 local function default_set_user_xml(user, host, xml)
37 local jid = user.."@"..host; 38 local jid = jid_join(user, host);
38 local path = paths.join(prosody.paths.data, jid..".xml"); 39 local path = paths.join(prosody.paths.data, jid..".xml");
39 local f, err = io_open(path, "w"); 40 local f, err = io_open(path, "w");
40 if not f then return f, err; end 41 if not f then return f, err; end
41 if xml then 42 if xml then
42 local s = tostring(xml); 43 local s = tostring(xml);