From 91055b49bba7b0be8f2b25b96b0ae9ce2a4337ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= <jonas@wielicki.name>
Date: Sat, 15 Jan 2022 15:40:29 +0100
Subject: [PATCH] mod_storage_xep0227: treat roster metadata pseudo-entry
 correctly

The roster version is stored in a pseudo-item which has the key `false`.
The if condition in the touched code attempts to guard against this, but
it does not take into account that the jid prepping returns nil instead
of false.

By moving the jid prepping into the if, we can check for the metadata
entry safely.
---
 plugins/mod_storage_xep0227.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/mod_storage_xep0227.lua b/plugins/mod_storage_xep0227.lua
index 3cd783bca..a8f608b33 100644
--- a/plugins/mod_storage_xep0227.lua
+++ b/plugins/mod_storage_xep0227.lua
@@ -250,8 +250,8 @@ handlers.roster = {
 				local roster = st.stanza("query", {xmlns='jabber:iq:roster'});
 				usere:add_child(roster);
 				for contact_jid, item in pairs(data) do
-					contact_jid = jid_bare(jid_prep(contact_jid));
 					if contact_jid ~= false then
+						contact_jid = jid_bare(jid_prep(contact_jid));
 						if contact_jid ~= user_jid then -- Skip self-contacts
 							roster:tag("item", {
 								jid = contact_jid,