Software /
code /
prosody
Comparison
plugins/mod_storage_xep0227.lua @ 12188:0fee75871f78
mod_storage_xep0227: be defensive against empty vCard
An empty vCard store may look like the empty table, which does not have
the `attr` key, which would then blow up in util.stanza.deserialize.
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Sat, 15 Jan 2022 15:39:13 +0100 |
parent | 12185:708769a4c5da |
child | 12189:82c8e855c850 |
comparison
equal
deleted
inserted
replaced
12187:94253e02d47d | 12188:0fee75871f78 |
---|---|
158 set = function(self, user, data) | 158 set = function(self, user, data) |
159 local xml = self:_get_user_xml(user, self.host); | 159 local xml = self:_get_user_xml(user, self.host); |
160 local usere = xml and getUserElement(xml); | 160 local usere = xml and getUserElement(xml); |
161 if usere then | 161 if usere then |
162 usere:remove_children("vCard", "vcard-temp"); | 162 usere:remove_children("vCard", "vcard-temp"); |
163 if not data then | 163 if not data or not data.attr then |
164 -- No data to set, old one deleted, success | 164 -- No data to set, old one deleted, success |
165 return true; | 165 return true; |
166 end | 166 end |
167 local vcard = st.deserialize(data); | 167 local vcard = st.deserialize(data); |
168 usere:add_child(vcard); | 168 usere:add_child(vcard); |