aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_memory.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-03-05 00:16:41 +0100
committerKim Alvefur <zash@zash.se>2019-03-05 00:16:41 +0100
commit59b4972c34a6887caf3ecb8b96d088fef831d9e9 (patch)
tree14fcea1707d3f42d1683bbecee2fe4b9983a0320 /plugins/mod_storage_memory.lua
parentcf5c64cd690c92ae7705fe6e7acce2ed81610ec2 (diff)
downloadprosody-59b4972c34a6887caf3ecb8b96d088fef831d9e9.tar.gz
prosody-59b4972c34a6887caf3ecb8b96d088fef831d9e9.zip
mod_storage_memory: Return error if 'before' or 'after' are not found (partial fix for #1325)
Diffstat (limited to 'plugins/mod_storage_memory.lua')
-rw-r--r--plugins/mod_storage_memory.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/mod_storage_memory.lua b/plugins/mod_storage_memory.lua
index 4655cb3a..2fae8828 100644
--- a/plugins/mod_storage_memory.lua
+++ b/plugins/mod_storage_memory.lua
@@ -127,20 +127,30 @@ function archive_store:find(username, query)
if query.reverse then
items:reverse();
if query.before then
+ local found = false;
for j = 1, #items do
if (items[j].key or tostring(j)) == query.before then
+ found = true;
i = j;
break;
end
end
+ if not found then
+ return nil, "item-not-found";
+ end
end
elseif query.after then
+ local found = false;
for j = 1, #items do
if (items[j].key or tostring(j)) == query.after then
+ found = true;
i = j;
break;
end
end
+ if not found then
+ return nil, "item-not-found";
+ end
end
if query.limit and #items - i > query.limit then
items[i+query.limit+1] = nil;