diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2021-08-23 21:28:15 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2021-08-23 21:28:15 +0200 |
commit | c952cc420b345a0e43fc4e6d819b3edb3ac12cb1 (patch) | |
tree | 294b7bb95d6b0fd6363079e200681190296a5354 | |
parent | Fix syntax in mod_disco example configuration (diff) |
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.
-rw-r--r-- | src/node_flat_sql.erl | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/node_flat_sql.erl b/src/node_flat_sql.erl index 724958eb1..240dc3760 100644 --- a/src/node_flat_sql.erl +++ b/src/node_flat_sql.erl @@ -1064,15 +1064,14 @@ rsm_page(Count, Index, Offset, Items) -> last = Last}. encode_stamp(Stamp) -> - case catch xmpp_util:decode_timestamp(Stamp) of - {MS,S,US} -> encode_now({MS,S,US}); - _ -> Stamp + try xmpp_util:decode_timestamp(Stamp) of + Now -> + encode_now(Now) + catch _:{bad_timestamp, _} -> + Stamp % We should return a proper error to the client instead. end. decode_stamp(Stamp) -> - case catch xmpp_util:encode_timestamp(decode_now(Stamp)) of - TimeStamp when is_binary(TimeStamp) -> TimeStamp; - _ -> Stamp - end. + xmpp_util:encode_timestamp(decode_now(Stamp)). encode_now({T1, T2, T3}) -> <<(misc:i2l(T1, 6))/binary, ":", |