]> granicus.if.org Git - ejabberd/commitdiff
don't route PEP error messsages to a client
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Tue, 9 Mar 2010 05:03:27 +0000 (14:03 +0900)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Tue, 9 Mar 2010 05:03:27 +0000 (14:03 +0900)
src/mod_pubsub/mod_pubsub.erl
src/mod_pubsub/mod_pubsub_odbc.erl

index e0b54ded221deb40e720bf2e68778abf65da6c4f..b7d45b7e1c87c45aaae973801f98ff68983c1243 100644 (file)
@@ -3769,7 +3769,9 @@ extended_headers(Jids) ->
     [{xmlelement, "address", [{"type", "replyto"}, {"jid", Jid}], []} || Jid <- Jids].
 
 
-feature_check_packet(allow, _User, Server, Pres, {#jid{lserver = LServer}, _To, {xmlelement, "message", _, _} = El}, in) ->
+feature_check_packet(allow, _User, Server, Pres,
+                    {#jid{lserver = LServer}, _To,
+                     {xmlelement, "message", MsgAttrs, _} = El}, in) ->
     Host = host(Server),
     case LServer of
        %% If the sender Server equals Host, the message comes from the Pubsub server
@@ -3781,12 +3783,27 @@ feature_check_packet(allow, _User, Server, Pres, {#jid{lserver = LServer}, _To,
                {xmlelement, _, Attrs, _} = EventEl ->
                    case xml:get_attr_s("xmlns", Attrs) of
                        ?NS_PUBSUB_EVENT ->
-                           Feature = xml:get_path_s(EventEl, [{elem, "items"}, {attr, "node"}]),
-                           case is_feature_supported(Pres, Feature) of
-                               true ->
-                                   allow;
-                               false ->
-                                   deny
+                           case xml:get_attr_s("type", MsgAttrs) of
+                               "error" ->
+                                   %% Filter error-repsonse of PEP message
+                                   %% to avoid routing it to client
+                                   deny;
+                               _ when Pres /= undefined ->
+                                   %% Yes, sometimes Pres = undefined,
+                                   %% very rare though.
+                                   %% Seems like this is a bug: should
+                                   %% be fixed in ejabberd_s2s.erl
+                                   Feature = xml:get_path_s(
+                                               EventEl, [{elem, "items"},
+                                                         {attr, "node"}]),
+                                   case is_feature_supported(Pres, Feature) of
+                                       true ->
+                                           allow;
+                                       false ->
+                                           deny
+                                   end;
+                               _ ->
+                                   allow
                            end;
                        _ ->
                            allow
index a6dca00350387d1d61e753bf21c1443ba1b9dbbe..cc783913bcc1d13bbd2429df334a24bc3889962c 100644 (file)
@@ -3634,7 +3634,9 @@ extended_headers(Jids) ->
     [{xmlelement, "address", [{"type", "replyto"}, {"jid", Jid}], []} || Jid <- Jids].
 
 
-feature_check_packet(allow, _User, Server, Pres, {#jid{lserver = LServer}, _To, {xmlelement, "message", _, _} = El}, in) ->
+feature_check_packet(allow, _User, Server, Pres,
+                    {#jid{lserver = LServer}, _To,
+                     {xmlelement, "message", MsgAttrs, _} = El}, in) ->
     Host = host(Server),
     case LServer of
        %% If the sender Server equals Host, the message comes from the Pubsub server
@@ -3646,12 +3648,27 @@ feature_check_packet(allow, _User, Server, Pres, {#jid{lserver = LServer}, _To,
                {xmlelement, _, Attrs, _} = EventEl ->
                    case xml:get_attr_s("xmlns", Attrs) of
                        ?NS_PUBSUB_EVENT ->
-                           Feature = xml:get_path_s(EventEl, [{elem, "items"}, {attr, "node"}]),
-                           case is_feature_supported(Pres, Feature) of
-                               true ->
-                                   allow;
-                               false ->
-                                   deny
+                           case xml:get_attr_s("type", MsgAttrs) of
+                               "error" ->
+                                   %% Filter error-repsonse of PEP message
+                                   %% to avoid routing it to client
+                                   deny;
+                               _ when Pres /= undefined ->
+                                   %% Yes, sometimes Pres = undefined,
+                                   %% very rare though.
+                                   %% Seems like this is a bug: should
+                                   %% be fixed in ejabberd_s2s.erl
+                                   Feature = xml:get_path_s(
+                                               EventEl, [{elem, "items"},
+                                                         {attr, "node"}]),
+                                   case is_feature_supported(Pres, Feature) of
+                                       true ->
+                                           allow;
+                                       false ->
+                                           deny
+                                   end;
+                               _ ->
+                                   allow
                            end;
                        _ ->
                            allow