From beeb1c82d92dabd37462db051fe9eb024ae12c41 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Sun, 24 Apr 2016 17:09:56 +0200 Subject: [PATCH] Fix check for standalone chat state notifications Ignore whitespace (and other XML CDATA) when checking whether a message stanza is a standalone chat state notification. --- src/jlib.erl | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/jlib.erl b/src/jlib.erl index 8eaebbc80..407f43f17 100644 --- a/src/jlib.erl +++ b/src/jlib.erl @@ -530,22 +530,13 @@ rsm_encode_count(Count, Arr) -> -spec is_standalone_chat_state(xmlel()) -> boolean(). -is_standalone_chat_state(#xmlel{name = <<"message">>} = El) -> +is_standalone_chat_state(#xmlel{name = <<"message">>, children = Els}) -> ChatStates = [<<"active">>, <<"inactive">>, <<"gone">>, <<"composing">>, <<"paused">>], - Stripped = - lists:foldl(fun(ChatState, AccEl) -> - fxml:remove_subtags(AccEl, ChatState, - {<<"xmlns">>, ?NS_CHATSTATES}) - end, El, ChatStates), - case Stripped of - #xmlel{children = [#xmlel{name = <<"thread">>}]} -> - true; - #xmlel{children = []} -> - true; - _ -> - false - end; + Stripped = [El || #xmlel{name = Name} = El <- Els, + not lists:member(Name, ChatStates), + Name /= <<"thread">>], + Stripped == []; is_standalone_chat_state(_El) -> false. -spec add_delay_info(xmlel(), jid() | ljid() | binary(), erlang:timestamp())