aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_internal.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-03-05 00:12:30 +0100
committerKim Alvefur <zash@zash.se>2019-03-05 00:12:30 +0100
commitb772308c93a1c78995a073964ebf963f759ef81c (patch)
tree990e385d87b19bbbe6a66db249fed5e308f88808 /plugins/mod_storage_internal.lua
parent48d6fa1aa122769a56d81c57276e46b27b63f101 (diff)
downloadprosody-b772308c93a1c78995a073964ebf963f759ef81c.tar.gz
prosody-b772308c93a1c78995a073964ebf963f759ef81c.zip
mod_storage_internal: Return error if 'before' or 'after' are not found (partial fix for #1325)
Diffstat (limited to 'plugins/mod_storage_internal.lua')
-rw-r--r--plugins/mod_storage_internal.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua
index 96780b33..fdce3c98 100644
--- a/plugins/mod_storage_internal.lua
+++ b/plugins/mod_storage_internal.lua
@@ -161,20 +161,30 @@ function archive: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;