node_flat_sql: Avoid catch-all clauses for RSM

Explicitly catch invalid <before/> and <after/> timestamps specified by
clients in RSM queries, but crash on other errors, rather than silently
ignoring those.
This commit is contained in:
Holger Weiss 2021-08-23 21:28:15 +02:00
parent 4d0503b6b3
commit c952cc420b
1 changed files with 6 additions and 7 deletions

View File

@ -1064,15 +1064,14 @@ rsm_page(Count, Index, Offset, Items) ->
last = Last}. last = Last}.
encode_stamp(Stamp) -> encode_stamp(Stamp) ->
case catch xmpp_util:decode_timestamp(Stamp) of try xmpp_util:decode_timestamp(Stamp) of
{MS,S,US} -> encode_now({MS,S,US}); Now ->
_ -> Stamp encode_now(Now)
catch _:{bad_timestamp, _} ->
Stamp % We should return a proper error to the client instead.
end. end.
decode_stamp(Stamp) -> decode_stamp(Stamp) ->
case catch xmpp_util:encode_timestamp(decode_now(Stamp)) of xmpp_util:encode_timestamp(decode_now(Stamp)).
TimeStamp when is_binary(TimeStamp) -> TimeStamp;
_ -> Stamp
end.
encode_now({T1, T2, T3}) -> encode_now({T1, T2, T3}) ->
<<(misc:i2l(T1, 6))/binary, ":", <<(misc:i2l(T1, 6))/binary, ":",