25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Switch to Fast XML module

This commit is contained in:
Mickael Remond 2016-02-03 19:03:17 +01:00
parent 5539db37b6
commit dfc29ea03c
63 changed files with 635 additions and 635 deletions

View File

@ -20,9 +20,9 @@
-include("ns.hrl"). -include("ns.hrl").
-ifdef(NO_EXT_LIB). -ifdef(NO_EXT_LIB).
-include("xml.hrl"). -include("fxml.hrl").
-else. -else.
-include_lib("p1_xml/include/xml.hrl"). -include_lib("fast_xml/include/fxml.hrl").
-endif. -endif.
-define(STANZA_ERROR(Code, Type, Condition), -define(STANZA_ERROR(Code, Type, Condition),

View File

@ -25,7 +25,7 @@ defmodule Ejabberd.Mixfile do
[mod: {:ejabberd_app, []}, [mod: {:ejabberd_app, []},
applications: [:ssl], applications: [:ssl],
included_applications: [:lager, :mnesia, :p1_utils, :cache_tab, included_applications: [:lager, :mnesia, :p1_utils, :cache_tab,
:fast_tls, :stringprep, :p1_xml, :fast_tls, :stringprep, :fast_xml,
:stun, :fast_yaml, :ezlib, :iconv, :stun, :fast_yaml, :ezlib, :iconv,
:esip, :jiffy, :p1_oauth2, :p1_xmlrpc, :eredis, :esip, :jiffy, :p1_oauth2, :p1_xmlrpc, :eredis,
:p1_mysql, :p1_pgsql, :sqlite3]] :p1_mysql, :p1_pgsql, :sqlite3]]
@ -39,12 +39,12 @@ defmodule Ejabberd.Mixfile do
defp deps do defp deps do
[{:lager, "~> 3.0"}, [{:lager, "~> 3.0"},
{:p1_utils, "~> 1.0", override: true}, {:p1_utils, "~> 1.0"},
{:cache_tab, "~> 1.0"}, {:cache_tab, "~> 1.0"},
{:stringprep, "~> 1.0"}, {:stringprep, "~> 1.0"},
{:fast_yaml, "~> 1.0"}, {:fast_yaml, "~> 1.0"},
{:fast_tls, "~> 1.0"}, {:fast_tls, "~> 1.0"},
{:p1_xml, git: "https://github.com/processone/xml", tag: "1.1.2"}, {:fast_xml, "~> 1.1"},
{:stun, "~> 1.0"}, {:stun, "~> 1.0"},
{:esip, "~> 1.0"}, {:esip, "~> 1.0"},
{:jiffy, "~> 0.14.7"}, {:jiffy, "~> 0.14.7"},

View File

@ -6,6 +6,7 @@
"exrm": {:hex, :exrm, "1.0.0-rc7"}, "exrm": {:hex, :exrm, "1.0.0-rc7"},
"ezlib": {:hex, :ezlib, "1.0.1"}, "ezlib": {:hex, :ezlib, "1.0.1"},
"fast_tls": {:hex, :fast_tls, "1.0.1"}, "fast_tls": {:hex, :fast_tls, "1.0.1"},
"fast_xml": {:hex, :fast_xml, "1.1.3"},
"fast_yaml": {:hex, :fast_yaml, "1.0.2"}, "fast_yaml": {:hex, :fast_yaml, "1.0.2"},
"getopt": {:hex, :getopt, "0.8.2"}, "getopt": {:hex, :getopt, "0.8.2"},
"goldrush": {:hex, :goldrush, "0.1.7"}, "goldrush": {:hex, :goldrush, "0.1.7"},
@ -16,7 +17,6 @@
"p1_oauth2": {:hex, :p1_oauth2, "0.6.1"}, "p1_oauth2": {:hex, :p1_oauth2, "0.6.1"},
"p1_pgsql": {:hex, :p1_pgsql, "1.0.1"}, "p1_pgsql": {:hex, :p1_pgsql, "1.0.1"},
"p1_utils": {:hex, :p1_utils, "1.0.3"}, "p1_utils": {:hex, :p1_utils, "1.0.3"},
"p1_xml": {:git, "https://github.com/processone/xml", "79c6d54e56bf991f1ec70ceb5e255afcb8dbf53f", [tag: "1.1.2"]},
"p1_xmlrpc": {:hex, :p1_xmlrpc, "1.15.1"}, "p1_xmlrpc": {:hex, :p1_xmlrpc, "1.15.1"},
"providers": {:hex, :providers, "1.4.1"}, "providers": {:hex, :providers, "1.4.1"},
"relx": {:hex, :relx, "3.5.0"}, "relx": {:hex, :relx, "3.5.0"},

View File

@ -12,7 +12,7 @@
{cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.2"}}}, {cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.2"}}},
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.1"}}}, {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.1"}}},
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.2"}}}, {stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.2"}}},
{p1_xml, ".*", {git, "https://github.com/processone/xml", {tag, "1.1.2"}}}, {fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.3"}}},
{stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.1"}}}, {stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.1"}}},
{esip, ".*", {git, "https://github.com/processone/esip", "1.0.2"}}, {esip, ".*", {git, "https://github.com/processone/esip", "1.0.2"}},
{fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.2"}}}, {fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.2"}}},
@ -38,7 +38,7 @@
{floating_deps, [cache_tab, {floating_deps, [cache_tab,
fast_tls, fast_tls,
stringprep, stringprep,
p1_xml, fast_xml,
esip, esip,
luerl, luerl,
stun, stun,
@ -97,7 +97,7 @@
{"stringprep", []}, {"stringprep", []},
{"fast_yaml", []}, {"fast_yaml", []},
{"esip", []}, {"esip", []},
{"p1_xml", [{if_var_true, full_xml, "--enable-full-xml"}]}, {"fast_xml", [{if_var_true, full_xml, "--enable-full-xml"}]},
{if_var_true, pam, {"p1_pam", []}}, {if_var_true, pam, {"p1_pam", []}},
{if_var_true, zlib, {"ezlib", []}}, {if_var_true, zlib, {"ezlib", []}},
{if_var_true, iconv, {"iconv", []}}]}. {if_var_true, iconv, {"iconv", []}}]}.

View File

@ -51,9 +51,9 @@
parse_request(#iq{type = set, lang = Lang, sub_el = SubEl, xmlns = ?NS_COMMANDS}) -> parse_request(#iq{type = set, lang = Lang, sub_el = SubEl, xmlns = ?NS_COMMANDS}) ->
?DEBUG("entering parse_request...", []), ?DEBUG("entering parse_request...", []),
Node = xml:get_tag_attr_s(<<"node">>, SubEl), Node = fxml:get_tag_attr_s(<<"node">>, SubEl),
SessionID = xml:get_tag_attr_s(<<"sessionid">>, SubEl), SessionID = fxml:get_tag_attr_s(<<"sessionid">>, SubEl),
Action = xml:get_tag_attr_s(<<"action">>, SubEl), Action = fxml:get_tag_attr_s(<<"action">>, SubEl),
XData = find_xdata_el(SubEl), XData = find_xdata_el(SubEl),
#xmlel{children = AllEls} = SubEl, #xmlel{children = AllEls} = SubEl,
Others = case XData of Others = case XData of
@ -76,7 +76,7 @@ find_xdata_el(#xmlel{children = SubEls}) ->
find_xdata_el1([]) -> false; find_xdata_el1([]) -> false;
find_xdata_el1([El | Els]) when is_record(El, xmlel) -> find_xdata_el1([El | Els]) when is_record(El, xmlel) ->
case xml:get_tag_attr_s(<<"xmlns">>, El) of case fxml:get_tag_attr_s(<<"xmlns">>, El) of
?NS_XDATA -> El; ?NS_XDATA -> El;
_ -> find_xdata_el1(Els) _ -> find_xdata_el1(Els)
end; end;

View File

@ -111,12 +111,12 @@ register_mechanism(Mechanism, Module, PasswordType) ->
%%-include("ejabberd.hrl"). %%-include("ejabberd.hrl").
%%-include("jlib.hrl"). %%-include("jlib.hrl").
%%check_authzid(_State, Props) -> %%check_authzid(_State, Props) ->
%% AuthzId = xml:get_attr_s(authzid, Props), %% AuthzId = fxml:get_attr_s(authzid, Props),
%% case jid:from_string(AuthzId) of %% case jid:from_string(AuthzId) of
%% error -> %% error ->
%% {error, "invalid-authzid"}; %% {error, "invalid-authzid"};
%% JID -> %% JID ->
%% LUser = jid:nodeprep(xml:get_attr_s(username, Props)), %% LUser = jid:nodeprep(fxml:get_attr_s(username, Props)),
%% {U, S, R} = jid:tolower(JID), %% {U, S, R} = jid:tolower(JID),
%% case R of %% case R of
%% "" -> %% "" ->

View File

@ -83,9 +83,9 @@ mech_step(#state{step = 3, nonce = Nonce} = State,
bad -> {error, <<"bad-protocol">>}; bad -> {error, <<"bad-protocol">>};
KeyVals -> KeyVals ->
DigestURI = proplists:get_value(<<"digest-uri">>, KeyVals, <<>>), DigestURI = proplists:get_value(<<"digest-uri">>, KeyVals, <<>>),
%DigestURI = xml:get_attr_s(<<"digest-uri">>, KeyVals), %DigestURI = fxml:get_attr_s(<<"digest-uri">>, KeyVals),
UserName = proplists:get_value(<<"username">>, KeyVals, <<>>), UserName = proplists:get_value(<<"username">>, KeyVals, <<>>),
%UserName = xml:get_attr_s(<<"username">>, KeyVals), %UserName = fxml:get_attr_s(<<"username">>, KeyVals),
case is_digesturi_valid(DigestURI, State#state.host, case is_digesturi_valid(DigestURI, State#state.host,
State#state.hostfqdn) State#state.hostfqdn)
of of
@ -97,13 +97,13 @@ mech_step(#state{step = 3, nonce = Nonce} = State,
{error, <<"not-authorized">>, UserName}; {error, <<"not-authorized">>, UserName};
true -> true ->
AuthzId = proplists:get_value(<<"authzid">>, KeyVals, <<>>), AuthzId = proplists:get_value(<<"authzid">>, KeyVals, <<>>),
%AuthzId = xml:get_attr_s(<<"authzid">>, KeyVals), %AuthzId = fxml:get_attr_s(<<"authzid">>, KeyVals),
case (State#state.get_password)(UserName) of case (State#state.get_password)(UserName) of
{false, _} -> {error, <<"not-authorized">>, UserName}; {false, _} -> {error, <<"not-authorized">>, UserName};
{Passwd, AuthModule} -> {Passwd, AuthModule} ->
case (State#state.check_password)(UserName, <<"">>, case (State#state.check_password)(UserName, <<"">>,
proplists:get_value(<<"response">>, KeyVals, <<>>), proplists:get_value(<<"response">>, KeyVals, <<>>),
%xml:get_attr_s(<<"response">>, KeyVals), %fxml:get_attr_s(<<"response">>, KeyVals),
fun (PW) -> fun (PW) ->
response(KeyVals, response(KeyVals,
UserName, UserName,

View File

@ -254,7 +254,7 @@ start_apps() ->
ejabberd:start_app(ssl), ejabberd:start_app(ssl),
ejabberd:start_app(fast_yaml), ejabberd:start_app(fast_yaml),
ejabberd:start_app(fast_tls), ejabberd:start_app(fast_tls),
ejabberd:start_app(p1_xml), ejabberd:start_app(fast_xml),
ejabberd:start_app(stringprep), ejabberd:start_app(stringprep),
ejabberd:start_app(ezlib), ejabberd:start_app(ezlib),
ejabberd:start_app(cache_tab). ejabberd:start_app(cache_tab).

View File

@ -342,15 +342,15 @@ get_subscribed(FsmRef) ->
wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) -> wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
DefaultLang = ?MYLANG, DefaultLang = ?MYLANG,
case xml:get_attr_s(<<"xmlns:stream">>, Attrs) of case fxml:get_attr_s(<<"xmlns:stream">>, Attrs) of
?NS_STREAM -> ?NS_STREAM ->
Server = Server =
case StateData#state.server of case StateData#state.server of
<<"">> -> <<"">> ->
jid:nameprep(xml:get_attr_s(<<"to">>, Attrs)); jid:nameprep(fxml:get_attr_s(<<"to">>, Attrs));
S -> S S -> S
end, end,
Lang = case xml:get_attr_s(<<"xml:lang">>, Attrs) of Lang = case fxml:get_attr_s(<<"xml:lang">>, Attrs) of
Lang1 when byte_size(Lang1) =< 35 -> Lang1 when byte_size(Lang1) =< 35 ->
%% As stated in BCP47, 4.4.1: %% As stated in BCP47, 4.4.1:
%% Protocols or specifications that %% Protocols or specifications that
@ -367,7 +367,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
case lists:member(Server, ?MYHOSTS) of case lists:member(Server, ?MYHOSTS) of
true when IsBlacklistedIP == false -> true when IsBlacklistedIP == false ->
change_shaper(StateData, jid:make(<<"">>, Server, <<"">>)), change_shaper(StateData, jid:make(<<"">>, Server, <<"">>)),
case xml:get_attr_s(<<"version">>, Attrs) of case fxml:get_attr_s(<<"version">>, Attrs) of
<<"1.0">> -> <<"1.0">> ->
send_header(StateData, Server, <<"1.0">>, DefaultLang), send_header(StateData, Server, <<"1.0">>, DefaultLang),
case StateData#state.authenticated of case StateData#state.authenticated of
@ -724,19 +724,19 @@ wait_for_feature_request({xmlstreamelement, El},
TLSRequired = StateData#state.tls_required, TLSRequired = StateData#state.tls_required,
SockMod = SockMod =
(StateData#state.sockmod):get_sockmod(StateData#state.socket), (StateData#state.sockmod):get_sockmod(StateData#state.socket),
case {xml:get_attr_s(<<"xmlns">>, Attrs), Name} of case {fxml:get_attr_s(<<"xmlns">>, Attrs), Name} of
{?NS_SASL, <<"auth">>} {?NS_SASL, <<"auth">>}
when TLSEnabled or not TLSRequired -> when TLSEnabled or not TLSRequired ->
Mech = xml:get_attr_s(<<"mechanism">>, Attrs), Mech = fxml:get_attr_s(<<"mechanism">>, Attrs),
ClientIn = jlib:decode_base64(xml:get_cdata(Els)), ClientIn = jlib:decode_base64(fxml:get_cdata(Els)),
case cyrsasl:server_start(StateData#state.sasl_state, case cyrsasl:server_start(StateData#state.sasl_state,
Mech, ClientIn) Mech, ClientIn)
of of
{ok, Props} -> {ok, Props} ->
(StateData#state.sockmod):reset_stream(StateData#state.socket), (StateData#state.sockmod):reset_stream(StateData#state.socket),
%U = xml:get_attr_s(username, Props), %U = fxml:get_attr_s(username, Props),
U = proplists:get_value(username, Props, <<>>), U = proplists:get_value(username, Props, <<>>),
%AuthModule = xml:get_attr_s(auth_module, Props), %AuthModule = fxml:get_attr_s(auth_module, Props),
AuthModule = proplists:get_value(auth_module, Props, undefined), AuthModule = proplists:get_value(auth_module, Props, undefined),
?INFO_MSG("(~w) Accepted authentication for ~s " ?INFO_MSG("(~w) Accepted authentication for ~s "
"by ~p from ~s", "by ~p from ~s",
@ -802,7 +802,7 @@ wait_for_feature_request({xmlstreamelement, El},
StateData#state.tls_options)] StateData#state.tls_options)]
end, end,
Socket = StateData#state.socket, Socket = StateData#state.socket,
BProceed = xml:element_to_binary(#xmlel{name = <<"proceed">>, BProceed = fxml:element_to_binary(#xmlel{name = <<"proceed">>,
attrs = [{<<"xmlns">>, ?NS_TLS}]}), attrs = [{<<"xmlns">>, ?NS_TLS}]}),
TLSSocket = (StateData#state.sockmod):starttls(Socket, TLSSocket = (StateData#state.sockmod):starttls(Socket,
TLSOpts, TLSOpts,
@ -814,7 +814,7 @@ wait_for_feature_request({xmlstreamelement, El},
{?NS_COMPRESS, <<"compress">>} {?NS_COMPRESS, <<"compress">>}
when Zlib == true, when Zlib == true,
(SockMod == gen_tcp) or (SockMod == fast_tls) -> (SockMod == gen_tcp) or (SockMod == fast_tls) ->
case xml:get_subtag(El, <<"method">>) of case fxml:get_subtag(El, <<"method">>) of
false -> false ->
send_element(StateData, send_element(StateData,
#xmlel{name = <<"failure">>, #xmlel{name = <<"failure">>,
@ -824,10 +824,10 @@ wait_for_feature_request({xmlstreamelement, El},
attrs = [], children = []}]}), attrs = [], children = []}]}),
fsm_next_state(wait_for_feature_request, StateData); fsm_next_state(wait_for_feature_request, StateData);
Method -> Method ->
case xml:get_tag_cdata(Method) of case fxml:get_tag_cdata(Method) of
<<"zlib">> -> <<"zlib">> ->
Socket = StateData#state.socket, Socket = StateData#state.socket,
BCompressed = xml:element_to_binary(#xmlel{name = <<"compressed">>, BCompressed = fxml:element_to_binary(#xmlel{name = <<"compressed">>,
attrs = [{<<"xmlns">>, ?NS_COMPRESS}]}), attrs = [{<<"xmlns">>, ?NS_COMPRESS}]}),
ZlibSocket = (StateData#state.sockmod):compress(Socket, ZlibSocket = (StateData#state.sockmod):compress(Socket,
BCompressed), BCompressed),
@ -880,18 +880,18 @@ wait_for_sasl_response({xmlstreamelement, #xmlel{name = Name} = El}, StateData)
wait_for_sasl_response({xmlstreamelement, El}, wait_for_sasl_response({xmlstreamelement, El},
StateData) -> StateData) ->
#xmlel{name = Name, attrs = Attrs, children = Els} = El, #xmlel{name = Name, attrs = Attrs, children = Els} = El,
case {xml:get_attr_s(<<"xmlns">>, Attrs), Name} of case {fxml:get_attr_s(<<"xmlns">>, Attrs), Name} of
{?NS_SASL, <<"response">>} -> {?NS_SASL, <<"response">>} ->
ClientIn = jlib:decode_base64(xml:get_cdata(Els)), ClientIn = jlib:decode_base64(fxml:get_cdata(Els)),
case cyrsasl:server_step(StateData#state.sasl_state, case cyrsasl:server_step(StateData#state.sasl_state,
ClientIn) ClientIn)
of of
{ok, Props} -> {ok, Props} ->
catch catch
(StateData#state.sockmod):reset_stream(StateData#state.socket), (StateData#state.sockmod):reset_stream(StateData#state.socket),
% U = xml:get_attr_s(username, Props), % U = fxml:get_attr_s(username, Props),
U = proplists:get_value(username, Props, <<>>), U = proplists:get_value(username, Props, <<>>),
% AuthModule = xml:get_attr_s(auth_module, Props), % AuthModule = fxml:get_attr_s(auth_module, Props),
AuthModule = proplists:get_value(auth_module, Props, <<>>), AuthModule = proplists:get_value(auth_module, Props, <<>>),
?INFO_MSG("(~w) Accepted authentication for ~s " ?INFO_MSG("(~w) Accepted authentication for ~s "
"by ~p from ~s", "by ~p from ~s",
@ -912,9 +912,9 @@ wait_for_sasl_response({xmlstreamelement, El},
user = U}); user = U});
{ok, Props, ServerOut} -> {ok, Props, ServerOut} ->
(StateData#state.sockmod):reset_stream(StateData#state.socket), (StateData#state.sockmod):reset_stream(StateData#state.socket),
% U = xml:get_attr_s(username, Props), % U = fxml:get_attr_s(username, Props),
U = proplists:get_value(username, Props, <<>>), U = proplists:get_value(username, Props, <<>>),
% AuthModule = xml:get_attr_s(auth_module, Props), % AuthModule = fxml:get_attr_s(auth_module, Props),
AuthModule = proplists:get_value(auth_module, Props, undefined), AuthModule = proplists:get_value(auth_module, Props, undefined),
?INFO_MSG("(~w) Accepted authentication for ~s " ?INFO_MSG("(~w) Accepted authentication for ~s "
"by ~p from ~s", "by ~p from ~s",
@ -1035,7 +1035,7 @@ wait_for_bind({xmlstreamelement, El}, StateData) ->
#iq{type = set, xmlns = ?NS_BIND, sub_el = SubEl} = #iq{type = set, xmlns = ?NS_BIND, sub_el = SubEl} =
IQ -> IQ ->
U = StateData#state.user, U = StateData#state.user,
R1 = xml:get_path_s(SubEl, R1 = fxml:get_path_s(SubEl,
[{elem, <<"resource">>}, cdata]), [{elem, <<"resource">>}, cdata]),
R = case jid:resourceprep(R1) of R = case jid:resourceprep(R1) of
error -> error; error -> error;
@ -1207,24 +1207,24 @@ session_established2(El, StateData) ->
User = NewStateData#state.user, User = NewStateData#state.user,
Server = NewStateData#state.server, Server = NewStateData#state.server,
FromJID = NewStateData#state.jid, FromJID = NewStateData#state.jid,
To = xml:get_attr_s(<<"to">>, Attrs), To = fxml:get_attr_s(<<"to">>, Attrs),
ToJID = case To of ToJID = case To of
<<"">> -> jid:make(User, Server, <<"">>); <<"">> -> jid:make(User, Server, <<"">>);
_ -> jid:from_string(To) _ -> jid:from_string(To)
end, end,
NewEl1 = jlib:remove_attr(<<"xmlns">>, El), NewEl1 = jlib:remove_attr(<<"xmlns">>, El),
NewEl = case xml:get_attr_s(<<"xml:lang">>, Attrs) of NewEl = case fxml:get_attr_s(<<"xml:lang">>, Attrs) of
<<"">> -> <<"">> ->
case NewStateData#state.lang of case NewStateData#state.lang of
<<"">> -> NewEl1; <<"">> -> NewEl1;
Lang -> Lang ->
xml:replace_tag_attr(<<"xml:lang">>, Lang, NewEl1) fxml:replace_tag_attr(<<"xml:lang">>, Lang, NewEl1)
end; end;
_ -> NewEl1 _ -> NewEl1
end, end,
NewState = case ToJID of NewState = case ToJID of
error -> error ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"error">> -> NewStateData; <<"error">> -> NewStateData;
<<"result">> -> NewStateData; <<"result">> -> NewStateData;
_ -> _ ->
@ -1408,7 +1408,7 @@ handle_info({route, From, To,
StateData, StateData,
[{From, To, [{From, To,
Packet}]), Packet}]),
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"probe">> -> <<"probe">> ->
LFrom = jid:tolower(From), LFrom = jid:tolower(From),
LBFrom = LBFrom =
@ -1625,7 +1625,7 @@ handle_info({route, From, To,
allow -> allow ->
{true, Attrs, StateData}; {true, Attrs, StateData};
deny -> deny ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"error">> -> ok; <<"error">> -> ok;
<<"groupchat">> -> ok; <<"groupchat">> -> ok;
<<"headline">> -> ok; <<"headline">> -> ok;
@ -1844,7 +1844,7 @@ send_element(StateData, El) when StateData#state.xml_socket ->
(StateData#state.sockmod):send_xml(StateData#state.socket, (StateData#state.sockmod):send_xml(StateData#state.socket,
{xmlstreamelement, El}); {xmlstreamelement, El});
send_element(StateData, El) -> send_element(StateData, El) ->
send_text(StateData, xml:element_to_binary(El)). send_text(StateData, fxml:element_to_binary(El)).
send_stanza(StateData, Stanza) when StateData#state.csi_state == inactive -> send_stanza(StateData, Stanza) when StateData#state.csi_state == inactive ->
csi_filter_stanza(StateData, Stanza); csi_filter_stanza(StateData, Stanza);
@ -1924,7 +1924,7 @@ is_auth_packet(El) ->
is_stanza(#xmlel{name = Name, attrs = Attrs}) when Name == <<"message">>; is_stanza(#xmlel{name = Name, attrs = Attrs}) when Name == <<"message">>;
Name == <<"presence">>; Name == <<"presence">>;
Name == <<"iq">> -> Name == <<"iq">> ->
case xml:get_attr(<<"xmlns">>, Attrs) of case fxml:get_attr(<<"xmlns">>, Attrs) of
{value, NS} when NS /= <<"jabber:client">>, {value, NS} when NS /= <<"jabber:client">>,
NS /= <<"jabber:server">> -> NS /= <<"jabber:server">> ->
false; false;
@ -1936,7 +1936,7 @@ is_stanza(_El) ->
get_auth_tags([#xmlel{name = Name, children = Els} | L], get_auth_tags([#xmlel{name = Name, children = Els} | L],
U, P, D, R) -> U, P, D, R) ->
CData = xml:get_cdata(Els), CData = fxml:get_cdata(Els),
case Name of case Name of
<<"username">> -> get_auth_tags(L, CData, P, D, R); <<"username">> -> get_auth_tags(L, CData, P, D, R);
<<"password">> -> get_auth_tags(L, U, CData, D, R); <<"password">> -> get_auth_tags(L, U, CData, D, R);
@ -2003,11 +2003,11 @@ process_presence_probe(From, To, StateData) ->
%% User updates his presence (non-directed presence packet) %% User updates his presence (non-directed presence packet)
presence_update(From, Packet, StateData) -> presence_update(From, Packet, StateData) ->
#xmlel{attrs = Attrs} = Packet, #xmlel{attrs = Attrs} = Packet,
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"unavailable">> -> <<"unavailable">> ->
Status = case xml:get_subtag(Packet, <<"status">>) of Status = case fxml:get_subtag(Packet, <<"status">>) of
false -> <<"">>; false -> <<"">>;
StatusTag -> xml:get_tag_cdata(StatusTag) StatusTag -> fxml:get_tag_cdata(StatusTag)
end, end,
Info = [{ip, StateData#state.ip}, Info = [{ip, StateData#state.ip},
{conn, StateData#state.conn}, {conn, StateData#state.conn},
@ -2068,7 +2068,7 @@ presence_track(From, To, Packet, StateData) ->
LTo = jid:tolower(To), LTo = jid:tolower(To),
User = StateData#state.user, User = StateData#state.user,
Server = StateData#state.server, Server = StateData#state.server,
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"unavailable">> -> <<"unavailable">> ->
A = remove_element(LTo, StateData#state.pres_a), A = remove_element(LTo, StateData#state.pres_a),
check_privacy_route(From, StateData#state{pres_a = A}, From, To, Packet); check_privacy_route(From, StateData#state{pres_a = A}, From, To, Packet);
@ -2265,11 +2265,11 @@ update_priority(Priority, Packet, StateData) ->
StateData#state.resource, Priority, Packet, Info). StateData#state.resource, Priority, Packet, Info).
get_priority_from_presence(PresencePacket) -> get_priority_from_presence(PresencePacket) ->
case xml:get_subtag(PresencePacket, <<"priority">>) of case fxml:get_subtag(PresencePacket, <<"priority">>) of
false -> 0; false -> 0;
SubEl -> SubEl ->
case catch case catch
jlib:binary_to_integer(xml:get_tag_cdata(SubEl)) jlib:binary_to_integer(fxml:get_tag_cdata(SubEl))
of of
P when is_integer(P) -> P; P when is_integer(P) -> P;
_ -> 0 _ -> 0
@ -2346,21 +2346,21 @@ resend_subscription_requests(#state{user = User,
get_showtag(undefined) -> <<"unavailable">>; get_showtag(undefined) -> <<"unavailable">>;
get_showtag(Presence) -> get_showtag(Presence) ->
case xml:get_path_s(Presence, [{elem, <<"show">>}, cdata]) of case fxml:get_path_s(Presence, [{elem, <<"show">>}, cdata]) of
<<"">> -> <<"available">>; <<"">> -> <<"available">>;
ShowTag -> ShowTag ShowTag -> ShowTag
end. end.
get_statustag(undefined) -> <<"">>; get_statustag(undefined) -> <<"">>;
get_statustag(Presence) -> get_statustag(Presence) ->
xml:get_path_s(Presence, [{elem, <<"status">>}, cdata]). fxml:get_path_s(Presence, [{elem, <<"status">>}, cdata]).
process_unauthenticated_stanza(StateData, El) -> process_unauthenticated_stanza(StateData, El) ->
NewEl = case xml:get_tag_attr_s(<<"xml:lang">>, El) of NewEl = case fxml:get_tag_attr_s(<<"xml:lang">>, El) of
<<"">> -> <<"">> ->
case StateData#state.lang of case StateData#state.lang of
<<"">> -> El; <<"">> -> El;
Lang -> xml:replace_tag_attr(<<"xml:lang">>, Lang, El) Lang -> fxml:replace_tag_attr(<<"xml:lang">>, Lang, El)
end; end;
_ -> El _ -> El
end, end,
@ -2462,7 +2462,7 @@ is_ip_blacklisted({IP, _Port}, Lang) ->
%% Check from attributes %% Check from attributes
%% returns invalid-from|NewElement %% returns invalid-from|NewElement
check_from(El, FromJID) -> check_from(El, FromJID) ->
case xml:get_tag_attr(<<"from">>, El) of case fxml:get_tag_attr(<<"from">>, El) of
false -> false ->
El; El;
{value, SJID} -> {value, SJID} ->
@ -2573,7 +2573,7 @@ negotiate_stream_mgmt(_El, #state{resource = <<"">>} = StateData) ->
send_element(StateData, ?MGMT_UNEXPECTED_REQUEST(?NS_STREAM_MGMT_3)), send_element(StateData, ?MGMT_UNEXPECTED_REQUEST(?NS_STREAM_MGMT_3)),
StateData; StateData;
negotiate_stream_mgmt(#xmlel{name = Name, attrs = Attrs}, StateData) -> negotiate_stream_mgmt(#xmlel{name = Name, attrs = Attrs}, StateData) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
Xmlns when ?IS_SUPPORTED_MGMT_XMLNS(Xmlns) -> Xmlns when ?IS_SUPPORTED_MGMT_XMLNS(Xmlns) ->
case stream_mgmt_enabled(StateData) of case stream_mgmt_enabled(StateData) of
true -> true ->
@ -2601,7 +2601,7 @@ negotiate_stream_mgmt(#xmlel{name = Name, attrs = Attrs}, StateData) ->
end. end.
perform_stream_mgmt(#xmlel{name = Name, attrs = Attrs}, StateData) -> perform_stream_mgmt(#xmlel{name = Name, attrs = Attrs}, StateData) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
Xmlns when Xmlns == StateData#state.mgmt_xmlns -> Xmlns when Xmlns == StateData#state.mgmt_xmlns ->
case Name of case Name of
<<"r">> -> <<"r">> ->
@ -2626,10 +2626,10 @@ perform_stream_mgmt(#xmlel{name = Name, attrs = Attrs}, StateData) ->
handle_enable(#state{mgmt_timeout = DefaultTimeout, handle_enable(#state{mgmt_timeout = DefaultTimeout,
mgmt_max_timeout = MaxTimeout} = StateData, Attrs) -> mgmt_max_timeout = MaxTimeout} = StateData, Attrs) ->
Timeout = case xml:get_attr_s(<<"resume">>, Attrs) of Timeout = case fxml:get_attr_s(<<"resume">>, Attrs) of
ResumeAttr when ResumeAttr == <<"true">>; ResumeAttr when ResumeAttr == <<"true">>;
ResumeAttr == <<"1">> -> ResumeAttr == <<"1">> ->
MaxAttr = xml:get_attr_s(<<"max">>, Attrs), MaxAttr = fxml:get_attr_s(<<"max">>, Attrs),
case catch jlib:binary_to_integer(MaxAttr) of case catch jlib:binary_to_integer(MaxAttr) of
Max when is_integer(Max), Max > 0, Max =< MaxTimeout -> Max when is_integer(Max), Max > 0, Max =< MaxTimeout ->
Max; Max;
@ -2669,7 +2669,7 @@ handle_r(StateData) ->
StateData. StateData.
handle_a(StateData, Attrs) -> handle_a(StateData, Attrs) ->
case catch jlib:binary_to_integer(xml:get_attr_s(<<"h">>, Attrs)) of case catch jlib:binary_to_integer(fxml:get_attr_s(<<"h">>, Attrs)) of
H when is_integer(H), H >= 0 -> H when is_integer(H), H >= 0 ->
check_h_attribute(StateData, H); check_h_attribute(StateData, H);
_ -> _ ->
@ -2679,12 +2679,12 @@ handle_a(StateData, Attrs) ->
end. end.
handle_resume(StateData, Attrs) -> handle_resume(StateData, Attrs) ->
R = case xml:get_attr_s(<<"xmlns">>, Attrs) of R = case fxml:get_attr_s(<<"xmlns">>, Attrs) of
Xmlns when ?IS_SUPPORTED_MGMT_XMLNS(Xmlns) -> Xmlns when ?IS_SUPPORTED_MGMT_XMLNS(Xmlns) ->
case stream_mgmt_enabled(StateData) of case stream_mgmt_enabled(StateData) of
true -> true ->
case {xml:get_attr(<<"previd">>, Attrs), case {fxml:get_attr(<<"previd">>, Attrs),
catch jlib:binary_to_integer(xml:get_attr_s(<<"h">>, Attrs))} catch jlib:binary_to_integer(fxml:get_attr_s(<<"h">>, Attrs))}
of of
{{value, PrevID}, H} when is_integer(H), H >= 0 -> {{value, PrevID}, H} when is_integer(H), H >= 0 ->
case inherit_session_state(StateData, PrevID) of case inherit_session_state(StateData, PrevID) of
@ -2815,9 +2815,9 @@ handle_unacked_stanzas(StateData, F)
[N, jid:to_string(StateData#state.jid)]), [N, jid:to_string(StateData#state.jid)]),
lists:foreach( lists:foreach(
fun({_, Time, #xmlel{attrs = Attrs} = El}) -> fun({_, Time, #xmlel{attrs = Attrs} = El}) ->
From_s = xml:get_attr_s(<<"from">>, Attrs), From_s = fxml:get_attr_s(<<"from">>, Attrs),
From = jid:from_string(From_s), From = jid:from_string(From_s),
To_s = xml:get_attr_s(<<"to">>, Attrs), To_s = fxml:get_attr_s(<<"to">>, Attrs),
To = jid:from_string(To_s), To = jid:from_string(To_s),
F(From, To, El, Time) F(From, To, El, Time)
end, queue:to_list(Queue)) end, queue:to_list(Queue))
@ -2867,7 +2867,7 @@ handle_unacked_stanzas(StateData)
case is_encapsulated_forward(El) of case is_encapsulated_forward(El) of
true -> true ->
?DEBUG("Dropping forwarded message stanza from ~s", ?DEBUG("Dropping forwarded message stanza from ~s",
[xml:get_attr_s(<<"from">>, El#xmlel.attrs)]); [fxml:get_attr_s(<<"from">>, El#xmlel.attrs)]);
false -> false ->
case ejabberd_hooks:run_fold(message_is_archived, case ejabberd_hooks:run_fold(message_is_archived,
StateData#state.server, StateData#state.server,
@ -2886,9 +2886,9 @@ handle_unacked_stanzas(_StateData) ->
ok. ok.
is_encapsulated_forward(#xmlel{name = <<"message">>} = El) -> is_encapsulated_forward(#xmlel{name = <<"message">>} = El) ->
SubTag = case {xml:get_subtag(El, <<"sent">>), SubTag = case {fxml:get_subtag(El, <<"sent">>),
xml:get_subtag(El, <<"received">>), fxml:get_subtag(El, <<"received">>),
xml:get_subtag(El, <<"result">>)} of fxml:get_subtag(El, <<"result">>)} of
{false, false, false} -> {false, false, false} ->
false; false;
{Tag, false, false} -> {Tag, false, false} ->
@ -2901,7 +2901,7 @@ is_encapsulated_forward(#xmlel{name = <<"message">>} = El) ->
if SubTag == false -> if SubTag == false ->
false; false;
true -> true ->
case xml:get_subtag(SubTag, <<"forwarded">>) of case fxml:get_subtag(SubTag, <<"forwarded">>) of
false -> false ->
false; false;
_ -> _ ->
@ -2989,7 +2989,7 @@ csi_filter_stanza(#state{csi_state = CsiState, jid = JID} = StateData,
queue -> csi_queue_add(StateData, Stanza); queue -> csi_queue_add(StateData, Stanza);
drop -> StateData; drop -> StateData;
send -> send ->
From = xml:get_tag_attr_s(<<"from">>, Stanza), From = fxml:get_tag_attr_s(<<"from">>, Stanza),
StateData1 = csi_queue_send(StateData, From), StateData1 = csi_queue_send(StateData, From),
StateData2 = send_stanza(StateData1#state{csi_state = active}, StateData2 = send_stanza(StateData1#state{csi_state = active},
Stanza), Stanza),
@ -3000,7 +3000,7 @@ csi_queue_add(#state{csi_queue = Queue} = StateData, Stanza) ->
case length(StateData#state.csi_queue) >= csi_max_queue(StateData) of case length(StateData#state.csi_queue) >= csi_max_queue(StateData) of
true -> csi_queue_add(csi_queue_flush(StateData), Stanza); true -> csi_queue_add(csi_queue_flush(StateData), Stanza);
false -> false ->
From = xml:get_tag_attr_s(<<"from">>, Stanza), From = fxml:get_tag_attr_s(<<"from">>, Stanza),
NewQueue = lists:keystore(From, 1, Queue, {From, p1_time_compat:timestamp(), Stanza}), NewQueue = lists:keystore(From, 1, Queue, {From, p1_time_compat:timestamp(), Stanza}),
StateData#state{csi_queue = NewQueue} StateData#state{csi_queue = NewQueue}
end. end.

View File

@ -320,7 +320,7 @@ build_captcha_html(Id, Lang) ->
-spec process_reply(xmlel()) -> ok | {error, bad_match | not_found | malformed}. -spec process_reply(xmlel()) -> ok | {error, bad_match | not_found | malformed}.
process_reply(#xmlel{} = El) -> process_reply(#xmlel{} = El) ->
case xml:get_subtag(El, <<"x">>) of case fxml:get_subtag(El, <<"x">>) of
false -> {error, malformed}; false -> {error, malformed};
Xdata -> Xdata ->
Fields = jlib:parse_xdata_submit(Xdata), Fields = jlib:parse_xdata_submit(Xdata),

View File

@ -32,7 +32,7 @@
-include("ejabberd_commands.hrl"). -include("ejabberd_commands.hrl").
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-define(RAW(V), if HTMLOutput -> xml:crypt(iolist_to_binary(V)); true -> iolist_to_binary(V) end). -define(RAW(V), if HTMLOutput -> fxml:crypt(iolist_to_binary(V)); true -> iolist_to_binary(V) end).
-define(TAG(N), if HTMLOutput -> [<<"<", ??N, "/>">>]; true -> md_tag(N, <<"">>) end). -define(TAG(N), if HTMLOutput -> [<<"<", ??N, "/>">>]; true -> md_tag(N, <<"">>) end).
-define(TAG(N, V), if HTMLOutput -> [<<"<", ??N, ">">>, V, <<"</", ??N, ">">>]; true -> md_tag(N, V) end). -define(TAG(N, V), if HTMLOutput -> [<<"<", ??N, ">">>, V, <<"</", ??N, ">">>]; true -> md_tag(N, V) end).
-define(TAG(N, C, V), if HTMLOutput -> [<<"<", ??N, " class='", C, "'>">>, V, <<"</", ??N, ">">>]; true -> md_tag(N, V) end). -define(TAG(N, C, V), if HTMLOutput -> [<<"<", ??N, " class='", C, "'>">>, V, <<"</", ??N, ">">>]; true -> md_tag(N, V) end).

View File

@ -532,10 +532,10 @@ make_xhtml_output(State, Status, Headers, XHTML) ->
Data = case lists:member(html, Headers) of Data = case lists:member(html, Headers) of
true -> true ->
iolist_to_binary([?HTML_DOCTYPE, iolist_to_binary([?HTML_DOCTYPE,
xml:element_to_binary(XHTML)]); fxml:element_to_binary(XHTML)]);
_ -> _ ->
iolist_to_binary([?XHTML_DOCTYPE, iolist_to_binary([?XHTML_DOCTYPE,
xml:element_to_binary(XHTML)]) fxml:element_to_binary(XHTML)])
end, end,
Headers1 = case lists:keysearch(<<"Content-Type">>, 1, Headers1 = case lists:keysearch(<<"Content-Type">>, 1,
Headers) Headers)

View File

@ -224,7 +224,7 @@ process_request(Data, IP, HOpts) ->
of of
%% No existing session: %% No existing session:
{ok, {<<"">>, Rid, Attrs, Payload}} -> {ok, {<<"">>, Rid, Attrs, Payload}} ->
case xml:get_attr_s(<<"to">>, Attrs) of case fxml:get_attr_s(<<"to">>, Attrs) of
<<"">> -> <<"">> ->
?DEBUG("Session not created (Improper addressing)", []), ?DEBUG("Session not created (Improper addressing)", []),
{200, ?HEADER, {200, ?HEADER,
@ -248,13 +248,13 @@ process_request(Data, IP, HOpts) ->
end; end;
%% Existing session %% Existing session
{ok, {Sid, Rid, Attrs, Payload1}} -> {ok, {Sid, Rid, Attrs, Payload1}} ->
StreamStart = case xml:get_attr_s(<<"xmpp:restart">>, StreamStart = case fxml:get_attr_s(<<"xmpp:restart">>,
Attrs) Attrs)
of of
<<"true">> -> true; <<"true">> -> true;
_ -> false _ -> false
end, end,
Payload2 = case xml:get_attr_s(<<"type">>, Attrs) of Payload2 = case fxml:get_attr_s(<<"type">>, Attrs) of
<<"terminate">> -> <<"terminate">> ->
Payload1 ++ [{xmlstreamend, <<"stream:stream">>}]; Payload1 ++ [{xmlstreamend, <<"stream:stream">>}];
_ -> Payload1 _ -> Payload1
@ -280,7 +280,7 @@ process_request(Data, IP, HOpts) ->
handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs, handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs,
Payload, PayloadSize, IP) -> Payload, PayloadSize, IP) ->
?DEBUG("got pid: ~p", [Pid]), ?DEBUG("got pid: ~p", [Pid]),
Wait = case str:to_integer(xml:get_attr_s(<<"wait">>, Wait = case str:to_integer(fxml:get_attr_s(<<"wait">>,
Attrs)) Attrs))
of of
{error, _} -> ?MAX_WAIT; {error, _} -> ?MAX_WAIT;
@ -289,7 +289,7 @@ handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs,
true -> CWait true -> CWait
end end
end, end,
Hold = case str:to_integer(xml:get_attr_s(<<"hold">>, Hold = case str:to_integer(fxml:get_attr_s(<<"hold">>,
Attrs)) Attrs))
of of
{error, _} -> (?MAX_REQUESTS) - 1; {error, _} -> (?MAX_REQUESTS) - 1;
@ -299,7 +299,7 @@ handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs,
end end
end, end,
Pdelay = case Pdelay = case
str:to_integer(xml:get_attr_s(<<"process-delay">>, str:to_integer(fxml:get_attr_s(<<"process-delay">>,
Attrs)) Attrs))
of of
{error, _} -> ?PROCESS_DELAY_DEFAULT; {error, _} -> ?PROCESS_DELAY_DEFAULT;
@ -312,12 +312,12 @@ handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs,
?PROCESS_DELAY_MIN]) ?PROCESS_DELAY_MIN])
end, end,
Version = case catch Version = case catch
list_to_float(binary_to_list(xml:get_attr_s(<<"ver">>, Attrs))) list_to_float(binary_to_list(fxml:get_attr_s(<<"ver">>, Attrs)))
of of
{'EXIT', _} -> 0.0; {'EXIT', _} -> 0.0;
V -> V V -> V
end, end,
XmppVersion = xml:get_attr_s(<<"xmpp:version">>, Attrs), XmppVersion = fxml:get_attr_s(<<"xmpp:version">>, Attrs),
?DEBUG("Create session: ~p", [Sid]), ?DEBUG("Create session: ~p", [Sid]),
mnesia:dirty_write( mnesia:dirty_write(
#http_bind{id = Sid, #http_bind{id = Sid,
@ -589,8 +589,8 @@ process_http_put(#http_put{rid = Rid, attrs = Attrs,
Request, Request,
StateName, StateData, RidAllow) -> StateName, StateData, RidAllow) ->
?DEBUG("Actually processing request: ~p", [Request]), ?DEBUG("Actually processing request: ~p", [Request]),
Key = xml:get_attr_s(<<"key">>, Attrs), Key = fxml:get_attr_s(<<"key">>, Attrs),
NewKey = xml:get_attr_s(<<"newkey">>, Attrs), NewKey = fxml:get_attr_s(<<"newkey">>, Attrs),
KeyAllow = case RidAllow of KeyAllow = case RidAllow of
repeat -> true; repeat -> true;
false -> false; false -> false;
@ -801,7 +801,7 @@ handle_http_put_error(Reason,
case Reason of case Reason of
not_exists -> not_exists ->
{200, ?HEADER, {200, ?HEADER,
xml:element_to_binary(#xmlel{name = <<"body">>, fxml:element_to_binary(#xmlel{name = <<"body">>,
attrs = attrs =
[{<<"xmlns">>, ?NS_HTTP_BIND}, [{<<"xmlns">>, ?NS_HTTP_BIND},
{<<"type">>, <<"terminate">>}, {<<"type">>, <<"terminate">>},
@ -810,7 +810,7 @@ handle_http_put_error(Reason,
children = []})}; children = []})};
bad_key -> bad_key ->
{200, ?HEADER, {200, ?HEADER,
xml:element_to_binary(#xmlel{name = <<"body">>, fxml:element_to_binary(#xmlel{name = <<"body">>,
attrs = attrs =
[{<<"xmlns">>, ?NS_HTTP_BIND}, [{<<"xmlns">>, ?NS_HTTP_BIND},
{<<"type">>, <<"terminate">>}, {<<"type">>, <<"terminate">>},
@ -819,7 +819,7 @@ handle_http_put_error(Reason,
children = []})}; children = []})};
polling_too_frequently -> polling_too_frequently ->
{200, ?HEADER, {200, ?HEADER,
xml:element_to_binary(#xmlel{name = <<"body">>, fxml:element_to_binary(#xmlel{name = <<"body">>,
attrs = attrs =
[{<<"xmlns">>, ?NS_HTTP_BIND}, [{<<"xmlns">>, ?NS_HTTP_BIND},
{<<"type">>, <<"terminate">>}, {<<"type">>, <<"terminate">>},
@ -855,7 +855,7 @@ rid_allow(OldRid, NewRid, Attrs, Hold, MaxPause) ->
%% We did not miss any packet, we can process it immediately: %% We did not miss any packet, we can process it immediately:
NewRid == OldRid + 1 -> NewRid == OldRid + 1 ->
case catch case catch
jlib:binary_to_integer(xml:get_attr_s(<<"pause">>, jlib:binary_to_integer(fxml:get_attr_s(<<"pause">>,
Attrs)) Attrs))
of of
{'EXIT', _} -> {true, 0}; {'EXIT', _} -> {true, 0};
@ -929,9 +929,9 @@ prepare_outpacket_response(#http_bind{id = Sid,
_Rid, OutPacket, true) -> _Rid, OutPacket, true) ->
case OutPacket of case OutPacket of
[{xmlstreamstart, _, OutAttrs} | Els] -> [{xmlstreamstart, _, OutAttrs} | Els] ->
AuthID = xml:get_attr_s(<<"id">>, OutAttrs), AuthID = fxml:get_attr_s(<<"id">>, OutAttrs),
From = xml:get_attr_s(<<"from">>, OutAttrs), From = fxml:get_attr_s(<<"from">>, OutAttrs),
Version = xml:get_attr_s(<<"version">>, OutAttrs), Version = fxml:get_attr_s(<<"version">>, OutAttrs),
OutEls = case Els of OutEls = case Els of
[] -> []; [] -> [];
[{xmlstreamelement, [{xmlstreamelement,
@ -968,7 +968,7 @@ prepare_outpacket_response(#http_bind{id = Sid,
MaxInactivity = get_max_inactivity(To, ?MAX_INACTIVITY), MaxInactivity = get_max_inactivity(To, ?MAX_INACTIVITY),
MaxPause = get_max_pause(To), MaxPause = get_max_pause(To),
{200, ?HEADER, {200, ?HEADER,
xml:element_to_binary(#xmlel{name = <<"body">>, fxml:element_to_binary(#xmlel{name = <<"body">>,
attrs = attrs =
[{<<"xmlns">>, ?NS_HTTP_BIND}, [{<<"xmlns">>, ?NS_HTTP_BIND},
{<<"sid">>, Sid}, {<<"sid">>, Sid},
@ -1032,7 +1032,7 @@ send_outpacket(#http_bind{pid = FsmRef}, OutPacket) ->
TypedEls = lists:foldl(fun ({xmlstreamelement, El}, TypedEls = lists:foldl(fun ({xmlstreamelement, El},
Acc) -> Acc) ->
Acc ++ Acc ++
[xml:element_to_binary(check_default_xmlns(El))]; [fxml:element_to_binary(check_default_xmlns(El))];
({xmlstreamraw, R}, Acc) -> ({xmlstreamraw, R}, Acc) ->
Acc ++ [R] Acc ++ [R]
end, end,
@ -1067,7 +1067,7 @@ send_outpacket(#http_bind{pid = FsmRef}, OutPacket) ->
|| {xmlstreamelement, OEl} <- StreamTail] || {xmlstreamelement, OEl} <- StreamTail]
end, end,
{200, ?HEADER, {200, ?HEADER,
xml:element_to_binary(#xmlel{name = <<"body">>, fxml:element_to_binary(#xmlel{name = <<"body">>,
attrs = attrs =
[{<<"xmlns">>, [{<<"xmlns">>,
?NS_HTTP_BIND}], ?NS_HTTP_BIND}],
@ -1114,14 +1114,14 @@ parse_request(Data, PayloadSize, MaxStanzaSize) ->
?DEBUG("--- incoming data --- ~n~s~n --- END " ?DEBUG("--- incoming data --- ~n~s~n --- END "
"--- ", "--- ",
[Data]), [Data]),
case xml_stream:parse_element(Data) of case fxml_stream:parse_element(Data) of
#xmlel{name = <<"body">>, attrs = Attrs, #xmlel{name = <<"body">>, attrs = Attrs,
children = Els} -> children = Els} ->
Xmlns = xml:get_attr_s(<<"xmlns">>, Attrs), Xmlns = fxml:get_attr_s(<<"xmlns">>, Attrs),
if Xmlns /= (?NS_HTTP_BIND) -> {error, bad_request}; if Xmlns /= (?NS_HTTP_BIND) -> {error, bad_request};
true -> true ->
case catch case catch
jlib:binary_to_integer(xml:get_attr_s(<<"rid">>, jlib:binary_to_integer(fxml:get_attr_s(<<"rid">>,
Attrs)) Attrs))
of of
{'EXIT', _} -> {error, bad_request}; {'EXIT', _} -> {error, bad_request};
@ -1133,7 +1133,7 @@ parse_request(Data, PayloadSize, MaxStanzaSize) ->
end end
end, end,
Els), Els),
Sid = xml:get_attr_s(<<"sid">>, Attrs), Sid = fxml:get_attr_s(<<"sid">>, Attrs),
if PayloadSize =< MaxStanzaSize -> if PayloadSize =< MaxStanzaSize ->
{ok, {Sid, Rid, Attrs, FixedEls}}; {ok, {Sid, Rid, Attrs, FixedEls}};
true -> {size_limit, Sid} true -> {size_limit, Sid}
@ -1165,7 +1165,7 @@ set_inactivity_timer(_Pause, MaxInactivity) ->
elements_to_string([]) -> []; elements_to_string([]) -> [];
elements_to_string([El | Els]) -> elements_to_string([El | Els]) ->
[xml:element_to_binary(El) | elements_to_string(Els)]. [fxml:element_to_binary(El) | elements_to_string(Els)].
%% @spec (To, Default::integer()) -> integer() %% @spec (To, Default::integer()) -> integer()
%% where To = [] | {Host::string(), Version::string()} %% where To = [] | {Host::string(), Version::string()}
@ -1188,7 +1188,7 @@ get_max_pause(_) -> ?MAX_PAUSE.
check_default_xmlns(#xmlel{name = Name, attrs = Attrs, check_default_xmlns(#xmlel{name = Name, attrs = Attrs,
children = Els} = children = Els} =
El) -> El) ->
case xml:get_tag_attr_s(<<"xmlns">>, El) of case fxml:get_tag_attr_s(<<"xmlns">>, El) of
<<"">> -> <<"">> ->
#xmlel{name = Name, #xmlel{name = Name,
attrs = [{<<"xmlns">>, ?NS_CLIENT} | Attrs], attrs = [{<<"xmlns">>, ?NS_CLIENT} | Attrs],

View File

@ -171,11 +171,11 @@ handle_sync_event({send_xml, Packet}, _From, StateName,
{true, {xmlstreamelement, #xmlel{name=Name2} = El2}} -> {true, {xmlstreamelement, #xmlel{name=Name2} = El2}} ->
El3 = case Name2 of El3 = case Name2 of
<<"stream:", _/binary>> -> <<"stream:", _/binary>> ->
xml:replace_tag_attr(<<"xmlns:stream">>, ?NS_STREAM, El2); fxml:replace_tag_attr(<<"xmlns:stream">>, ?NS_STREAM, El2);
_ -> _ ->
case xml:get_tag_attr_s(<<"xmlns">>, El2) of case fxml:get_tag_attr_s(<<"xmlns">>, El2) of
<<"">> -> <<"">> ->
xml:replace_tag_attr(<<"xmlns">>, <<"jabber:client">>, El2); fxml:replace_tag_attr(<<"xmlns">>, <<"jabber:client">>, El2);
_ -> _ ->
El2 El2
end end
@ -186,12 +186,12 @@ handle_sync_event({send_xml, Packet}, _From, StateName,
end, end,
case Packet2 of case Packet2 of
{xmlstreamstart, Name, Attrs3} -> {xmlstreamstart, Name, Attrs3} ->
B = xml:element_to_binary(#xmlel{name = Name, attrs = Attrs3}), B = fxml:element_to_binary(#xmlel{name = Name, attrs = Attrs3}),
WsPid ! {send, <<(binary:part(B, 0, byte_size(B)-2))/binary, ">">>}; WsPid ! {send, <<(binary:part(B, 0, byte_size(B)-2))/binary, ">">>};
{xmlstreamend, Name} -> {xmlstreamend, Name} ->
WsPid ! {send, <<"</", Name/binary, ">">>}; WsPid ! {send, <<"</", Name/binary, ">">>};
{xmlstreamelement, El} -> {xmlstreamelement, El} ->
WsPid ! {send, xml:element_to_binary(El)}; WsPid ! {send, fxml:element_to_binary(El)};
{xmlstreamraw, Bin} -> {xmlstreamraw, Bin} ->
WsPid ! {send, Bin}; WsPid ! {send, Bin};
{xmlstreamcdata, Bin2} -> {xmlstreamcdata, Bin2} ->
@ -210,7 +210,7 @@ handle_sync_event(close, _From, StateName, #state{ws = {_, WsPid}, rfc_compilant
when StateName /= stream_end_sent -> when StateName /= stream_end_sent ->
Close = #xmlel{name = <<"close">>, Close = #xmlel{name = <<"close">>,
attrs = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>}]}, attrs = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>}]},
WsPid ! {send, xml:element_to_binary(Close)}, WsPid ! {send, fxml:element_to_binary(Close)},
{stop, normal, StateData}; {stop, normal, StateData};
handle_sync_event(close, _From, _StateName, StateData) -> handle_sync_event(close, _From, _StateName, StateData) ->
{stop, normal, StateData}. {stop, normal, StateData}.
@ -316,9 +316,9 @@ get_human_html_xmlel() ->
parse(#state{rfc_compilant = C} = State, Data) -> parse(#state{rfc_compilant = C} = State, Data) ->
case C of case C of
undefined -> undefined ->
P = xml_stream:new(self()), P = fxml_stream:new(self()),
P2 = xml_stream:parse(P, Data), P2 = fxml_stream:parse(P, Data),
xml_stream:close(P2), fxml_stream:close(P2),
case parsed_items([]) of case parsed_items([]) of
error -> error ->
{State#state{rfc_compilant = true}, <<"parse error">>}; {State#state{rfc_compilant = true}, <<"parse error">>};
@ -330,7 +330,7 @@ parse(#state{rfc_compilant = C} = State, Data) ->
parse(State#state{rfc_compilant = false}, Data) parse(State#state{rfc_compilant = false}, Data)
end; end;
true -> true ->
El = xml_stream:parse_element(Data), El = fxml_stream:parse_element(Data),
case El of case El of
#xmlel{name = <<"open">>, attrs = Attrs} -> #xmlel{name = <<"open">>, attrs = Attrs} ->
Attrs2 = [{<<"xmlns:stream">>, ?NS_STREAM}, {<<"xmlns">>, <<"jabber:client">>} | Attrs2 = [{<<"xmlns:stream">>, ?NS_STREAM}, {<<"xmlns">>, <<"jabber:client">>} |

View File

@ -272,7 +272,7 @@ do_route(From, To, Packet) ->
end; end;
true -> true ->
#xmlel{attrs = Attrs} = Packet, #xmlel{attrs = Attrs} = Packet,
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"error">> -> ok; <<"error">> -> ok;
<<"result">> -> ok; <<"result">> -> ok;
_ -> _ ->

View File

@ -64,7 +64,7 @@
-define(NS_PIEFXIS, <<"http://www.xmpp.org/extensions/xep-0227.html#ns">>). -define(NS_PIEFXIS, <<"http://www.xmpp.org/extensions/xep-0227.html#ns">>).
-define(NS_XI, <<"http://www.w3.org/2001/XInclude">>). -define(NS_XI, <<"http://www.w3.org/2001/XInclude">>).
-record(state, {xml_stream_state :: xml_stream:xml_stream_state(), -record(state, {xml_stream_state :: fxml_stream:xml_stream_state(),
user = <<"">> :: binary(), user = <<"">> :: binary(),
server = <<"">> :: binary(), server = <<"">> :: binary(),
fd :: file:io_device(), fd :: file:io_device(),
@ -85,7 +85,7 @@ import_file(FileName, State) ->
case file:open(FileName, [read, binary]) of case file:open(FileName, [read, binary]) of
{ok, Fd} -> {ok, Fd} ->
Dir = filename:dirname(FileName), Dir = filename:dirname(FileName),
XMLStreamState = xml_stream:new(self(), infinity), XMLStreamState = fxml_stream:new(self(), infinity),
Res = process(State#state{xml_stream_state = XMLStreamState, Res = process(State#state{xml_stream_state = XMLStreamState,
fd = Fd, fd = Fd,
dir = Dir}), dir = Dir}),
@ -257,7 +257,7 @@ export_user(User, Server, Fd) ->
get_privacy(User, Server) ++ get_privacy(User, Server) ++
get_roster(User, Server) ++ get_roster(User, Server) ++
get_private(User, Server), get_private(User, Server),
print(Fd, xml:element_to_binary( print(Fd, fxml:element_to_binary(
#xmlel{name = <<"user">>, #xmlel{name = <<"user">>,
attrs = [{<<"name">>, User}, attrs = [{<<"name">>, User},
{<<"password">>, Pass}], {<<"password">>, Pass}],
@ -387,17 +387,17 @@ get_private(User, Server) ->
process(#state{xml_stream_state = XMLStreamState, fd = Fd} = State) -> process(#state{xml_stream_state = XMLStreamState, fd = Fd} = State) ->
case file:read(Fd, ?CHUNK_SIZE) of case file:read(Fd, ?CHUNK_SIZE) of
{ok, Data} -> {ok, Data} ->
NewXMLStreamState = xml_stream:parse(XMLStreamState, Data), NewXMLStreamState = fxml_stream:parse(XMLStreamState, Data),
case process_els(State#state{xml_stream_state = case process_els(State#state{xml_stream_state =
NewXMLStreamState}) of NewXMLStreamState}) of
{ok, NewState} -> {ok, NewState} ->
process(NewState); process(NewState);
Err -> Err ->
xml_stream:close(NewXMLStreamState), fxml_stream:close(NewXMLStreamState),
Err Err
end; end;
eof -> eof ->
xml_stream:close(XMLStreamState), fxml_stream:close(XMLStreamState),
ok ok
end. end.
@ -415,7 +415,7 @@ process_els(State) ->
end. end.
process_el({xmlstreamstart, <<"server-data">>, Attrs}, State) -> process_el({xmlstreamstart, <<"server-data">>, Attrs}, State) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_PIEFXIS -> ?NS_PIEFXIS ->
{ok, State}; {ok, State};
?NS_PIE -> ?NS_PIE ->
@ -430,7 +430,7 @@ process_el({xmlstreamcdata, _}, State) ->
process_el({xmlstreamelement, #xmlel{name = <<"xi:include">>, process_el({xmlstreamelement, #xmlel{name = <<"xi:include">>,
attrs = Attrs}}, attrs = Attrs}},
#state{dir = Dir, user = <<"">>} = State) -> #state{dir = Dir, user = <<"">>} = State) ->
FileName = xml:get_attr_s(<<"href">>, Attrs), FileName = fxml:get_attr_s(<<"href">>, Attrs),
case import_file(filename:join([Dir, FileName]), State) of case import_file(filename:join([Dir, FileName]), State) of
ok -> ok ->
{ok, State}; {ok, State};
@ -443,7 +443,7 @@ process_el({xmlstreamstart, <<"host">>, Attrs}, State) ->
process_el({xmlstreamelement, #xmlel{name = <<"host">>, process_el({xmlstreamelement, #xmlel{name = <<"host">>,
attrs = Attrs, attrs = Attrs,
children = Els}}, State) -> children = Els}}, State) ->
JIDS = xml:get_attr_s(<<"jid">>, Attrs), JIDS = fxml:get_attr_s(<<"jid">>, Attrs),
case jid:from_string(JIDS) of case jid:from_string(JIDS) of
#jid{lserver = S} -> #jid{lserver = S} ->
case lists:member(S, ?MYHOSTS) of case lists:member(S, ?MYHOSTS) of
@ -486,8 +486,8 @@ process_users([], State) ->
process_user(#xmlel{name = <<"user">>, attrs = Attrs, children = Els}, process_user(#xmlel{name = <<"user">>, attrs = Attrs, children = Els},
#state{server = LServer} = State) -> #state{server = LServer} = State) ->
Name = xml:get_attr_s(<<"name">>, Attrs), Name = fxml:get_attr_s(<<"name">>, Attrs),
Password = xml:get_attr_s(<<"password">>, Attrs), Password = fxml:get_attr_s(<<"password">>, Attrs),
PasswordFormat = ejabberd_config:get_option({auth_password_format, LServer}, fun(X) -> X end, plain), PasswordFormat = ejabberd_config:get_option({auth_password_format, LServer}, fun(X) -> X end, plain),
Pass = case PasswordFormat of Pass = case PasswordFormat of
scram -> scram ->
@ -525,7 +525,7 @@ process_user_els([], State) ->
process_user_el(#xmlel{name = Name, attrs = Attrs, children = Els} = El, process_user_el(#xmlel{name = Name, attrs = Attrs, children = Els} = El,
State) -> State) ->
case {Name, xml:get_attr_s(<<"xmlns">>, Attrs)} of case {Name, fxml:get_attr_s(<<"xmlns">>, Attrs)} of
{<<"query">>, ?NS_ROSTER} -> {<<"query">>, ?NS_ROSTER} ->
process_roster(El, State); process_roster(El, State);
{<<"query">>, ?NS_PRIVACY} -> {<<"query">>, ?NS_PRIVACY} ->
@ -584,7 +584,7 @@ process_privacy(El, State = #state{user = U, server = S}) ->
[], JID, JID, #iq{type = set, sub_el = El}) of [], JID, JID, #iq{type = set, sub_el = El}) of
{error, Error} = Err -> {error, Error} = Err ->
#xmlel{children = Els} = El, #xmlel{children = Els} = El,
Name = case xml:remove_cdata(Els) of Name = case fxml:remove_cdata(Els) of
[#xmlel{name = N}] -> N; [#xmlel{name = N}] -> N;
_ -> undefined _ -> undefined
end, end,
@ -628,7 +628,7 @@ process_vcard(El, State = #state{user = U, server = S}) ->
%% @spec (Dir::string(), Host::string()) -> ok %% @spec (Dir::string(), Host::string()) -> ok
process_offline_msg(El, State = #state{user = U, server = S}) -> process_offline_msg(El, State = #state{user = U, server = S}) ->
FromS = xml:get_attr_s(<<"from">>, El#xmlel.attrs), FromS = fxml:get_attr_s(<<"from">>, El#xmlel.attrs),
case jid:from_string(FromS) of case jid:from_string(FromS) of
#jid{} = From -> #jid{} = From ->
To = jid:make(U, S, <<>>), To = jid:make(U, S, <<>>),
@ -645,7 +645,7 @@ process_offline_msg(El, State = #state{user = U, server = S}) ->
%% @spec (Dir::string(), Fn::string(), Host::string()) -> ok %% @spec (Dir::string(), Fn::string(), Host::string()) -> ok
process_presence(El, #state{user = U, server = S} = State) -> process_presence(El, #state{user = U, server = S} = State) ->
FromS = xml:get_attr_s(<<"from">>, El#xmlel.attrs), FromS = fxml:get_attr_s(<<"from">>, El#xmlel.attrs),
case jid:from_string(FromS) of case jid:from_string(FromS) of
#jid{} = From -> #jid{} = From ->
To = jid:make(U, S, <<>>), To = jid:make(U, S, <<>>),

View File

@ -53,7 +53,7 @@
shaper_state = none :: shaper:shaper(), shaper_state = none :: shaper:shaper(),
c2s_pid :: pid(), c2s_pid :: pid(),
max_stanza_size = infinity :: non_neg_integer() | infinity, max_stanza_size = infinity :: non_neg_integer() | infinity,
xml_stream_state :: xml_stream:xml_stream_state(), xml_stream_state :: fxml_stream:xml_stream_state(),
timeout = infinity:: timeout()}). timeout = infinity:: timeout()}).
-define(HIBERNATE_TIMEOUT, 90000). -define(HIBERNATE_TIMEOUT, 90000).
@ -160,7 +160,7 @@ handle_call(reset_stream, _From, State) ->
Reply = ok, Reply = ok,
{reply, Reply, NewState, ?HIBERNATE_TIMEOUT}; {reply, Reply, NewState, ?HIBERNATE_TIMEOUT};
handle_call({become_controller, C2SPid}, _From, State) -> handle_call({become_controller, C2SPid}, _From, State) ->
XMLStreamState = xml_stream:new(C2SPid, State#state.max_stanza_size), XMLStreamState = fxml_stream:new(C2SPid, State#state.max_stanza_size),
NewState = State#state{c2s_pid = C2SPid, NewState = State#state{c2s_pid = C2SPid,
xml_stream_state = XMLStreamState}, xml_stream_state = XMLStreamState},
activate_socket(NewState), activate_socket(NewState),
@ -284,7 +284,7 @@ process_data(Data,
undefined -> undefined ->
XMLStreamState; XMLStreamState;
_ -> _ ->
xml_stream:parse(XMLStreamState, Data) fxml_stream:parse(XMLStreamState, Data)
end, end,
{NewShaperState, Pause} = shaper:update(ShaperState, byte_size(Data)), {NewShaperState, Pause} = shaper:update(ShaperState, byte_size(Data)),
if if
@ -309,7 +309,7 @@ element_wrapper(Element) -> Element.
close_stream(undefined) -> ok; close_stream(undefined) -> ok;
close_stream(XMLStreamState) -> close_stream(XMLStreamState) ->
xml_stream:close(XMLStreamState). fxml_stream:close(XMLStreamState).
reset_parser(#state{xml_stream_state = undefined} = State) -> reset_parser(#state{xml_stream_state = undefined} = State) ->
State; State;
@ -317,14 +317,14 @@ reset_parser(#state{c2s_pid = C2SPid,
max_stanza_size = MaxStanzaSize, max_stanza_size = MaxStanzaSize,
xml_stream_state = XMLStreamState} xml_stream_state = XMLStreamState}
= State) -> = State) ->
NewStreamState = try xml_stream:reset(XMLStreamState) NewStreamState = try fxml_stream:reset(XMLStreamState)
catch error:_ -> catch error:_ ->
close_stream(XMLStreamState), close_stream(XMLStreamState),
case C2SPid of case C2SPid of
undefined -> undefined ->
undefined; undefined;
_ -> _ ->
xml_stream:new(C2SPid, MaxStanzaSize) fxml_stream:new(C2SPid, MaxStanzaSize)
end end
end, end,
State#state{xml_stream_state = NewStreamState}. State#state{xml_stream_state = NewStreamState}.

View File

@ -86,7 +86,7 @@ route(From, To, Packet) ->
route_error(From, To, ErrPacket, OrigPacket) -> route_error(From, To, ErrPacket, OrigPacket) ->
#xmlel{attrs = Attrs} = OrigPacket, #xmlel{attrs = Attrs} = OrigPacket,
case <<"error">> == xml:get_attr_s(<<"type">>, Attrs) of case <<"error">> == fxml:get_attr_s(<<"type">>, Attrs) of
false -> route(From, To, ErrPacket); false -> route(From, To, ErrPacket);
true -> ok true -> ok
end. end.

View File

@ -308,7 +308,7 @@ do_route(From, To, Packet) ->
#xmlel{name = Name, attrs = NewAttrs, children = Els}), #xmlel{name = Name, attrs = NewAttrs, children = Els}),
ok; ok;
{aborted, _Reason} -> {aborted, _Reason} ->
case xml:get_tag_attr_s(<<"type">>, Packet) of case fxml:get_tag_attr_s(<<"type">>, Packet) of
<<"error">> -> ok; <<"error">> -> ok;
<<"result">> -> ok; <<"result">> -> ok;
_ -> _ ->

View File

@ -85,16 +85,16 @@
-define(STREAM_TRAILER, <<"</stream:stream>">>). -define(STREAM_TRAILER, <<"</stream:stream>">>).
-define(INVALID_NAMESPACE_ERR, -define(INVALID_NAMESPACE_ERR,
xml:element_to_binary(?SERR_INVALID_NAMESPACE)). fxml:element_to_binary(?SERR_INVALID_NAMESPACE)).
-define(HOST_UNKNOWN_ERR, -define(HOST_UNKNOWN_ERR,
xml:element_to_binary(?SERR_HOST_UNKNOWN)). fxml:element_to_binary(?SERR_HOST_UNKNOWN)).
-define(INVALID_FROM_ERR, -define(INVALID_FROM_ERR,
xml:element_to_binary(?SERR_INVALID_FROM)). fxml:element_to_binary(?SERR_INVALID_FROM)).
-define(INVALID_XML_ERR, -define(INVALID_XML_ERR,
xml:element_to_binary(?SERR_XML_NOT_WELL_FORMED)). fxml:element_to_binary(?SERR_XML_NOT_WELL_FORMED)).
start(SockData, Opts) -> start(SockData, Opts) ->
supervisor:start_child(ejabberd_s2s_in_sup, supervisor:start_child(ejabberd_s2s_in_sup,
@ -188,10 +188,10 @@ init([{SockMod, Socket}, Opts]) ->
wait_for_stream({xmlstreamstart, _Name, Attrs}, wait_for_stream({xmlstreamstart, _Name, Attrs},
StateData) -> StateData) ->
case {xml:get_attr_s(<<"xmlns">>, Attrs), case {fxml:get_attr_s(<<"xmlns">>, Attrs),
xml:get_attr_s(<<"xmlns:db">>, Attrs), fxml:get_attr_s(<<"xmlns:db">>, Attrs),
xml:get_attr_s(<<"to">>, Attrs), fxml:get_attr_s(<<"to">>, Attrs),
xml:get_attr_s(<<"version">>, Attrs) == <<"1.0">>} fxml:get_attr_s(<<"version">>, Attrs) == <<"1.0">>}
of of
{<<"jabber:server">>, _, Server, true} {<<"jabber:server">>, _, Server, true}
when StateData#state.tls and when StateData#state.tls and
@ -199,7 +199,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs},
send_text(StateData, send_text(StateData,
?STREAM_HEADER(<<" version='1.0'">>)), ?STREAM_HEADER(<<" version='1.0'">>)),
Auth = if StateData#state.tls_enabled -> Auth = if StateData#state.tls_enabled ->
case jid:nameprep(xml:get_attr_s(<<"from">>, Attrs)) of case jid:nameprep(fxml:get_attr_s(<<"from">>, Attrs)) of
From when From /= <<"">>, From /= error -> From when From /= <<"">>, From /= error ->
{Result, Message} = {Result, Message} =
ejabberd_s2s:check_peer_certificate(StateData#state.sockmod, ejabberd_s2s:check_peer_certificate(StateData#state.sockmod,
@ -234,7 +234,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs},
?INFO_MSG("Closing s2s connection: ~s <--> ~s (~s)", ?INFO_MSG("Closing s2s connection: ~s <--> ~s (~s)",
[StateData#state.server, RemoteServer, CertError]), [StateData#state.server, RemoteServer, CertError]),
send_text(StateData, send_text(StateData,
<<(xml:element_to_binary(?SERRT_POLICY_VIOLATION(<<"en">>, <<(fxml:element_to_binary(?SERRT_POLICY_VIOLATION(<<"en">>,
CertError)))/binary, CertError)))/binary,
(?STREAM_TRAILER)/binary>>), (?STREAM_TRAILER)/binary>>),
{stop, normal, StateData}; {stop, normal, StateData};
@ -306,7 +306,7 @@ wait_for_feature_request({xmlstreamelement, El},
TLSEnabled = StateData#state.tls_enabled, TLSEnabled = StateData#state.tls_enabled,
SockMod = SockMod =
(StateData#state.sockmod):get_sockmod(StateData#state.socket), (StateData#state.sockmod):get_sockmod(StateData#state.socket),
case {xml:get_attr_s(<<"xmlns">>, Attrs), Name} of case {fxml:get_attr_s(<<"xmlns">>, Attrs), Name} of
{?NS_TLS, <<"starttls">>} {?NS_TLS, <<"starttls">>}
when TLS == true, TLSEnabled == false, when TLS == true, TLSEnabled == false,
SockMod == gen_tcp -> SockMod == gen_tcp ->
@ -331,7 +331,7 @@ wait_for_feature_request({xmlstreamelement, El},
end, end,
TLSSocket = (StateData#state.sockmod):starttls(Socket, TLSSocket = (StateData#state.sockmod):starttls(Socket,
TLSOpts, TLSOpts,
xml:element_to_binary(#xmlel{name fxml:element_to_binary(#xmlel{name
= =
<<"proceed">>, <<"proceed">>,
attrs attrs
@ -345,7 +345,7 @@ wait_for_feature_request({xmlstreamelement, El},
StateData#state{socket = TLSSocket, streamid = new_id(), StateData#state{socket = TLSSocket, streamid = new_id(),
tls_enabled = true, tls_options = TLSOpts}}; tls_enabled = true, tls_options = TLSOpts}};
{?NS_SASL, <<"auth">>} when TLSEnabled -> {?NS_SASL, <<"auth">>} when TLSEnabled ->
Mech = xml:get_attr_s(<<"mechanism">>, Attrs), Mech = fxml:get_attr_s(<<"mechanism">>, Attrs),
case Mech of case Mech of
<<"EXTERNAL">> when StateData#state.auth_domain /= <<"">> -> <<"EXTERNAL">> when StateData#state.auth_domain /= <<"">> ->
AuthDomain = StateData#state.auth_domain, AuthDomain = StateData#state.auth_domain,
@ -447,9 +447,9 @@ stream_established({xmlstreamelement, El}, StateData) ->
_ -> _ ->
NewEl = jlib:remove_attr(<<"xmlns">>, El), NewEl = jlib:remove_attr(<<"xmlns">>, El),
#xmlel{name = Name, attrs = Attrs} = NewEl, #xmlel{name = Name, attrs = Attrs} = NewEl,
From_s = xml:get_attr_s(<<"from">>, Attrs), From_s = fxml:get_attr_s(<<"from">>, Attrs),
From = jid:from_string(From_s), From = jid:from_string(From_s),
To_s = xml:get_attr_s(<<"to">>, Attrs), To_s = fxml:get_attr_s(<<"to">>, Attrs),
To = jid:from_string(To_s), To = jid:from_string(To_s),
if (To /= error) and (From /= error) -> if (To /= error) and (From /= error) ->
LFrom = From#jid.lserver, LFrom = From#jid.lserver,
@ -626,7 +626,7 @@ send_text(StateData, Text) ->
Text). Text).
send_element(StateData, El) -> send_element(StateData, El) ->
send_text(StateData, xml:element_to_binary(El)). send_text(StateData, fxml:element_to_binary(El)).
change_shaper(StateData, Host, JID) -> change_shaper(StateData, Host, JID) ->
Shaper = acl:match_rule(Host, StateData#state.shaper, Shaper = acl:match_rule(Host, StateData#state.shaper,
@ -643,15 +643,15 @@ cancel_timer(Timer) ->
is_key_packet(#xmlel{name = Name, attrs = Attrs, is_key_packet(#xmlel{name = Name, attrs = Attrs,
children = Els}) children = Els})
when Name == <<"db:result">> -> when Name == <<"db:result">> ->
{key, xml:get_attr_s(<<"to">>, Attrs), {key, fxml:get_attr_s(<<"to">>, Attrs),
xml:get_attr_s(<<"from">>, Attrs), fxml:get_attr_s(<<"from">>, Attrs),
xml:get_attr_s(<<"id">>, Attrs), xml:get_cdata(Els)}; fxml:get_attr_s(<<"id">>, Attrs), fxml:get_cdata(Els)};
is_key_packet(#xmlel{name = Name, attrs = Attrs, is_key_packet(#xmlel{name = Name, attrs = Attrs,
children = Els}) children = Els})
when Name == <<"db:verify">> -> when Name == <<"db:verify">> ->
{verify, xml:get_attr_s(<<"to">>, Attrs), {verify, fxml:get_attr_s(<<"to">>, Attrs),
xml:get_attr_s(<<"from">>, Attrs), fxml:get_attr_s(<<"from">>, Attrs),
xml:get_attr_s(<<"id">>, Attrs), xml:get_cdata(Els)}; fxml:get_attr_s(<<"id">>, Attrs), fxml:get_cdata(Els)};
is_key_packet(_) -> false. is_key_packet(_) -> false.
fsm_limit_opts(Opts) -> fsm_limit_opts(Opts) ->

View File

@ -105,13 +105,13 @@
-define(STREAM_TRAILER, <<"</stream:stream>">>). -define(STREAM_TRAILER, <<"</stream:stream>">>).
-define(INVALID_NAMESPACE_ERR, -define(INVALID_NAMESPACE_ERR,
xml:element_to_binary(?SERR_INVALID_NAMESPACE)). fxml:element_to_binary(?SERR_INVALID_NAMESPACE)).
-define(HOST_UNKNOWN_ERR, -define(HOST_UNKNOWN_ERR,
xml:element_to_binary(?SERR_HOST_UNKNOWN)). fxml:element_to_binary(?SERR_HOST_UNKNOWN)).
-define(INVALID_XML_ERR, -define(INVALID_XML_ERR,
xml:element_to_binary(?SERR_XML_NOT_WELL_FORMED)). fxml:element_to_binary(?SERR_XML_NOT_WELL_FORMED)).
-define(SOCKET_DEFAULT_RESULT, {error, badarg}). -define(SOCKET_DEFAULT_RESULT, {error, badarg}).
@ -323,15 +323,15 @@ wait_for_stream({xmlstreamstart, _Name, Attrs},
true -> true ->
{no_verify, <<"Not verified">>, StateData} {no_verify, <<"Not verified">>, StateData}
end, end,
RemoteStreamID = xml:get_attr_s(<<"id">>, Attrs), RemoteStreamID = fxml:get_attr_s(<<"id">>, Attrs),
NewStateData = StateData0#state{remote_streamid = RemoteStreamID}, NewStateData = StateData0#state{remote_streamid = RemoteStreamID},
case {xml:get_attr_s(<<"xmlns">>, Attrs), case {fxml:get_attr_s(<<"xmlns">>, Attrs),
xml:get_attr_s(<<"xmlns:db">>, Attrs), fxml:get_attr_s(<<"xmlns:db">>, Attrs),
xml:get_attr_s(<<"version">>, Attrs) == <<"1.0">>} fxml:get_attr_s(<<"version">>, Attrs) == <<"1.0">>}
of of
_ when CertCheckRes == error -> _ when CertCheckRes == error ->
send_text(NewStateData, send_text(NewStateData,
<<(xml:element_to_binary(?SERRT_POLICY_VIOLATION(<<"en">>, <<(fxml:element_to_binary(?SERRT_POLICY_VIOLATION(<<"en">>,
CertCheckMsg)))/binary, CertCheckMsg)))/binary,
(?STREAM_TRAILER)/binary>>), (?STREAM_TRAILER)/binary>>),
?INFO_MSG("Closing s2s connection: ~s -> ~s (~s)", ?INFO_MSG("Closing s2s connection: ~s -> ~s (~s)",
@ -495,7 +495,7 @@ wait_for_features({xmlstreamelement, El}, StateData) ->
STLSReq} = STLSReq} =
Acc) -> Acc) ->
case case
xml:get_attr_s(<<"xmlns">>, fxml:get_attr_s(<<"xmlns">>,
Attrs1) Attrs1)
of of
?NS_SASL -> ?NS_SASL ->
@ -508,7 +508,7 @@ wait_for_features({xmlstreamelement, El}, StateData) ->
= =
Els2}) -> Els2}) ->
case case
xml:get_cdata(Els2) fxml:get_cdata(Els2)
of of
<<"EXTERNAL">> -> <<"EXTERNAL">> ->
true; true;
@ -533,13 +533,13 @@ wait_for_features({xmlstreamelement, El}, StateData) ->
_STLSReq} = _STLSReq} =
Acc) -> Acc) ->
case case
xml:get_attr_s(<<"xmlns">>, fxml:get_attr_s(<<"xmlns">>,
Attrs1) Attrs1)
of of
?NS_TLS -> ?NS_TLS ->
Req = Req =
case case
xml:get_subtag(El1, fxml:get_subtag(El1,
<<"required">>) <<"required">>)
of of
#xmlel{} -> #xmlel{} ->
@ -610,7 +610,7 @@ wait_for_features({xmlstreamelement, El}, StateData) ->
end; end;
_ -> _ ->
send_text(StateData, send_text(StateData,
<<(xml:element_to_binary(?SERR_BAD_FORMAT))/binary, <<(fxml:element_to_binary(?SERR_BAD_FORMAT))/binary,
(?STREAM_TRAILER)/binary>>), (?STREAM_TRAILER)/binary>>),
?INFO_MSG("Closing s2s connection: ~s -> ~s (bad " ?INFO_MSG("Closing s2s connection: ~s -> ~s (bad "
"format)", "format)",
@ -637,7 +637,7 @@ wait_for_auth_result({xmlstreamelement, El},
StateData) -> StateData) ->
case El of case El of
#xmlel{name = <<"success">>, attrs = Attrs} -> #xmlel{name = <<"success">>, attrs = Attrs} ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_SASL -> ?NS_SASL ->
?DEBUG("auth: ~p", ?DEBUG("auth: ~p",
[{StateData#state.myname, StateData#state.server}]), [{StateData#state.myname, StateData#state.server}]),
@ -653,7 +653,7 @@ wait_for_auth_result({xmlstreamelement, El},
?FSMTIMEOUT}; ?FSMTIMEOUT};
_ -> _ ->
send_text(StateData, send_text(StateData,
<<(xml:element_to_binary(?SERR_BAD_FORMAT))/binary, <<(fxml:element_to_binary(?SERR_BAD_FORMAT))/binary,
(?STREAM_TRAILER)/binary>>), (?STREAM_TRAILER)/binary>>),
?INFO_MSG("Closing s2s connection: ~s -> ~s (bad " ?INFO_MSG("Closing s2s connection: ~s -> ~s (bad "
"format)", "format)",
@ -661,7 +661,7 @@ wait_for_auth_result({xmlstreamelement, El},
{stop, normal, StateData} {stop, normal, StateData}
end; end;
#xmlel{name = <<"failure">>, attrs = Attrs} -> #xmlel{name = <<"failure">>, attrs = Attrs} ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_SASL -> ?NS_SASL ->
?DEBUG("restarted: ~p", ?DEBUG("restarted: ~p",
[{StateData#state.myname, StateData#state.server}]), [{StateData#state.myname, StateData#state.server}]),
@ -670,7 +670,7 @@ wait_for_auth_result({xmlstreamelement, El},
StateData#state{socket = undefined}, ?FSMTIMEOUT}; StateData#state{socket = undefined}, ?FSMTIMEOUT};
_ -> _ ->
send_text(StateData, send_text(StateData,
<<(xml:element_to_binary(?SERR_BAD_FORMAT))/binary, <<(fxml:element_to_binary(?SERR_BAD_FORMAT))/binary,
(?STREAM_TRAILER)/binary>>), (?STREAM_TRAILER)/binary>>),
?INFO_MSG("Closing s2s connection: ~s -> ~s (bad " ?INFO_MSG("Closing s2s connection: ~s -> ~s (bad "
"format)", "format)",
@ -679,7 +679,7 @@ wait_for_auth_result({xmlstreamelement, El},
end; end;
_ -> _ ->
send_text(StateData, send_text(StateData,
<<(xml:element_to_binary(?SERR_BAD_FORMAT))/binary, <<(fxml:element_to_binary(?SERR_BAD_FORMAT))/binary,
(?STREAM_TRAILER)/binary>>), (?STREAM_TRAILER)/binary>>),
?INFO_MSG("Closing s2s connection: ~s -> ~s (bad " ?INFO_MSG("Closing s2s connection: ~s -> ~s (bad "
"format)", "format)",
@ -707,7 +707,7 @@ wait_for_starttls_proceed({xmlstreamelement, El},
StateData) -> StateData) ->
case El of case El of
#xmlel{name = <<"proceed">>, attrs = Attrs} -> #xmlel{name = <<"proceed">>, attrs = Attrs} ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_TLS -> ?NS_TLS ->
?DEBUG("starttls: ~p", ?DEBUG("starttls: ~p",
[{StateData#state.myname, StateData#state.server}]), [{StateData#state.myname, StateData#state.server}]),
@ -737,7 +737,7 @@ wait_for_starttls_proceed({xmlstreamelement, El},
?FSMTIMEOUT}; ?FSMTIMEOUT};
_ -> _ ->
send_text(StateData, send_text(StateData,
<<(xml:element_to_binary(?SERR_BAD_FORMAT))/binary, <<(fxml:element_to_binary(?SERR_BAD_FORMAT))/binary,
(?STREAM_TRAILER)/binary>>), (?STREAM_TRAILER)/binary>>),
?INFO_MSG("Closing s2s connection: ~s -> ~s (bad " ?INFO_MSG("Closing s2s connection: ~s -> ~s (bad "
"format)", "format)",
@ -985,7 +985,7 @@ send_text(StateData, Text) ->
ejabberd_socket:send(StateData#state.socket, Text). ejabberd_socket:send(StateData#state.socket, Text).
send_element(StateData, El) -> send_element(StateData, El) ->
send_text(StateData, xml:element_to_binary(El)). send_text(StateData, fxml:element_to_binary(El)).
send_queue(StateData, Q) -> send_queue(StateData, Q) ->
case queue:out(Q) of case queue:out(Q) of
@ -997,14 +997,14 @@ send_queue(StateData, Q) ->
%% Bounce a single message (xmlelement) %% Bounce a single message (xmlelement)
bounce_element(El, Error) -> bounce_element(El, Error) ->
#xmlel{attrs = Attrs} = El, #xmlel{attrs = Attrs} = El,
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"error">> -> ok; <<"error">> -> ok;
<<"result">> -> ok; <<"result">> -> ok;
_ -> _ ->
Err = jlib:make_error_reply(El, Error), Err = jlib:make_error_reply(El, Error),
From = jid:from_string(xml:get_tag_attr_s(<<"from">>, From = jid:from_string(fxml:get_tag_attr_s(<<"from">>,
El)), El)),
To = jid:from_string(xml:get_tag_attr_s(<<"to">>, To = jid:from_string(fxml:get_tag_attr_s(<<"to">>,
El)), El)),
ejabberd_router:route(To, From, Err) ejabberd_router:route(To, From, Err)
end. end.
@ -1070,16 +1070,16 @@ send_db_request(StateData) ->
is_verify_res(#xmlel{name = Name, attrs = Attrs}) is_verify_res(#xmlel{name = Name, attrs = Attrs})
when Name == <<"db:result">> -> when Name == <<"db:result">> ->
{result, xml:get_attr_s(<<"to">>, Attrs), {result, fxml:get_attr_s(<<"to">>, Attrs),
xml:get_attr_s(<<"from">>, Attrs), fxml:get_attr_s(<<"from">>, Attrs),
xml:get_attr_s(<<"id">>, Attrs), fxml:get_attr_s(<<"id">>, Attrs),
xml:get_attr_s(<<"type">>, Attrs)}; fxml:get_attr_s(<<"type">>, Attrs)};
is_verify_res(#xmlel{name = Name, attrs = Attrs}) is_verify_res(#xmlel{name = Name, attrs = Attrs})
when Name == <<"db:verify">> -> when Name == <<"db:verify">> ->
{verify, xml:get_attr_s(<<"to">>, Attrs), {verify, fxml:get_attr_s(<<"to">>, Attrs),
xml:get_attr_s(<<"from">>, Attrs), fxml:get_attr_s(<<"from">>, Attrs),
xml:get_attr_s(<<"id">>, Attrs), fxml:get_attr_s(<<"id">>, Attrs),
xml:get_attr_s(<<"type">>, Attrs)}; fxml:get_attr_s(<<"type">>, Attrs)};
is_verify_res(_) -> false. is_verify_res(_) -> false.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@ -91,10 +91,10 @@
"m:error></stream:stream>">>). "m:error></stream:stream>">>).
-define(INVALID_XML_ERR, -define(INVALID_XML_ERR,
xml:element_to_binary(?SERR_XML_NOT_WELL_FORMED)). fxml:element_to_binary(?SERR_XML_NOT_WELL_FORMED)).
-define(INVALID_NS_ERR, -define(INVALID_NS_ERR,
xml:element_to_binary(?SERR_INVALID_NAMESPACE)). fxml:element_to_binary(?SERR_INVALID_NAMESPACE)).
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% API %%% API
@ -166,9 +166,9 @@ init([{SockMod, Socket}, Opts]) ->
wait_for_stream({xmlstreamstart, _Name, Attrs}, wait_for_stream({xmlstreamstart, _Name, Attrs},
StateData) -> StateData) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
<<"jabber:component:accept">> -> <<"jabber:component:accept">> ->
To = xml:get_attr_s(<<"to">>, Attrs), To = fxml:get_attr_s(<<"to">>, Attrs),
Host = jid:nameprep(To), Host = jid:nameprep(To),
if Host == error -> if Host == error ->
Header = io_lib:format(?STREAM_HEADER, Header = io_lib:format(?STREAM_HEADER,
@ -180,7 +180,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs},
{stop, normal, StateData}; {stop, normal, StateData};
true -> true ->
Header = io_lib:format(?STREAM_HEADER, Header = io_lib:format(?STREAM_HEADER,
[StateData#state.streamid, xml:crypt(To)]), [StateData#state.streamid, fxml:crypt(To)]),
send_text(StateData, Header), send_text(StateData, Header),
HostOpts = case dict:is_key(Host, StateData#state.host_opts) of HostOpts = case dict:is_key(Host, StateData#state.host_opts) of
true -> true ->
@ -212,7 +212,7 @@ wait_for_stream(closed, StateData) ->
wait_for_handshake({xmlstreamelement, El}, StateData) -> wait_for_handshake({xmlstreamelement, El}, StateData) ->
#xmlel{name = Name, children = Els} = El, #xmlel{name = Name, children = Els} = El,
case {Name, xml:get_cdata(Els)} of case {Name, fxml:get_cdata(Els)} of
{<<"handshake">>, Digest} -> {<<"handshake">>, Digest} ->
case dict:find(StateData#state.host, StateData#state.host_opts) of case dict:find(StateData#state.host, StateData#state.host_opts) of
{ok, Password} -> {ok, Password} ->
@ -250,7 +250,7 @@ wait_for_handshake(closed, StateData) ->
stream_established({xmlstreamelement, El}, StateData) -> stream_established({xmlstreamelement, El}, StateData) ->
NewEl = jlib:remove_attr(<<"xmlns">>, El), NewEl = jlib:remove_attr(<<"xmlns">>, El),
#xmlel{name = Name, attrs = Attrs} = NewEl, #xmlel{name = Name, attrs = Attrs} = NewEl,
From = xml:get_attr_s(<<"from">>, Attrs), From = fxml:get_attr_s(<<"from">>, Attrs),
FromJID = case StateData#state.check_from of FromJID = case StateData#state.check_from of
%% If the admin does not want to check the from field %% If the admin does not want to check the from field
%% when accept packets from any address. %% when accept packets from any address.
@ -269,7 +269,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
_ -> error _ -> error
end end
end, end,
To = xml:get_attr_s(<<"to">>, Attrs), To = fxml:get_attr_s(<<"to">>, Attrs),
ToJID = case To of ToJID = case To of
<<"">> -> error; <<"">> -> error;
_ -> jid:from_string(To) _ -> jid:from_string(To)
@ -356,7 +356,7 @@ handle_info({route, From, To, Packet}, StateName,
Attrs2 = Attrs2 =
jlib:replace_from_to_attrs(jid:to_string(From), jlib:replace_from_to_attrs(jid:to_string(From),
jid:to_string(To), Attrs), jid:to_string(To), Attrs),
Text = xml:element_to_binary(#xmlel{name = Name, Text = fxml:element_to_binary(#xmlel{name = Name,
attrs = Attrs2, children = Els}), attrs = Attrs2, children = Els}),
send_text(StateData, Text); send_text(StateData, Text);
deny -> deny ->
@ -402,7 +402,7 @@ send_text(StateData, Text) ->
Text). Text).
send_element(StateData, El) -> send_element(StateData, El) ->
send_text(StateData, xml:element_to_binary(El)). send_text(StateData, fxml:element_to_binary(El)).
new_id() -> randoms:get_string(). new_id() -> randoms:get_string().

View File

@ -419,10 +419,10 @@ do_route(From, To, #xmlel{} = Packet) ->
<<"">> -> <<"">> ->
case Name of case Name of
<<"presence">> -> <<"presence">> ->
{Pass, _Subsc} = case xml:get_attr_s(<<"type">>, Attrs) {Pass, _Subsc} = case fxml:get_attr_s(<<"type">>, Attrs)
of of
<<"subscribe">> -> <<"subscribe">> ->
Reason = xml:get_path_s(Packet, Reason = fxml:get_path_s(Packet,
[{elem, [{elem,
<<"status">>}, <<"status">>},
cdata]), cdata]),
@ -483,7 +483,7 @@ do_route(From, To, #xmlel{} = Packet) ->
true -> ok true -> ok
end; end;
<<"message">> -> <<"message">> ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"chat">> -> route_message(From, To, Packet, chat); <<"chat">> -> route_message(From, To, Packet, chat);
<<"headline">> -> route_message(From, To, Packet, headline); <<"headline">> -> route_message(From, To, Packet, headline);
<<"error">> -> ok; <<"error">> -> ok;
@ -503,7 +503,7 @@ do_route(From, To, #xmlel{} = Packet) ->
[] -> [] ->
case Name of case Name of
<<"message">> -> <<"message">> ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"chat">> -> route_message(From, To, Packet, chat); <<"chat">> -> route_message(From, To, Packet, chat);
<<"normal">> -> route_message(From, To, Packet, normal); <<"normal">> -> route_message(From, To, Packet, normal);
<<"">> -> route_message(From, To, Packet, normal); <<"">> -> route_message(From, To, Packet, normal);
@ -514,7 +514,7 @@ do_route(From, To, #xmlel{} = Packet) ->
ejabberd_router:route(To, From, Err) ejabberd_router:route(To, From, Err)
end; end;
<<"iq">> -> <<"iq">> ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"error">> -> ok; <<"error">> -> ok;
<<"result">> -> ok; <<"result">> -> ok;
_ -> _ ->

View File

@ -71,7 +71,7 @@ process_command(From, To, Packet) ->
jid:tolower(jid:remove_resource(From)), jid:tolower(jid:remove_resource(From)),
case lists:member(LFrom, get_admin_jids()) of case lists:member(LFrom, get_admin_jids()) of
true -> true ->
Body = xml:get_path_s(Packet, Body = fxml:get_path_s(Packet,
[{elem, <<"body">>}, cdata]), [{elem, <<"body">>}, cdata]),
spawn(fun () -> spawn(fun () ->
process_flag(priority, high), process_flag(priority, high),

View File

@ -2722,14 +2722,14 @@ pretty_print_xml(#xmlel{name = Name, attrs = Attrs,
[{Attr, Val} | RestAttrs] -> [{Attr, Val} | RestAttrs] ->
AttrPrefix = [Prefix, AttrPrefix = [Prefix,
str:copies(<<" ">>, byte_size(Name) + 2)], str:copies(<<" ">>, byte_size(Name) + 2)],
[$\s, Attr, $=, $', xml:crypt(Val) | [$', [$\s, Attr, $=, $', fxml:crypt(Val) | [$',
lists:map(fun ({Attr1, lists:map(fun ({Attr1,
Val1}) -> Val1}) ->
[$\n, [$\n,
AttrPrefix, AttrPrefix,
Attr1, $=, Attr1, $=,
$', $',
xml:crypt(Val1), fxml:crypt(Val1),
$'] $']
end, end,
RestAttrs)]] RestAttrs)]]
@ -2741,7 +2741,7 @@ pretty_print_xml(#xmlel{name = Name, attrs = Attrs,
end, end,
Els), Els),
if OnlyCData -> if OnlyCData ->
[$>, xml:get_cdata(Els), $<, $/, Name, $>, $\n]; [$>, fxml:get_cdata(Els), $<, $/, Name, $>, $\n];
true -> true ->
[$>, $\n, [$>, $\n,
lists:map(fun (E) -> lists:map(fun (E) ->

View File

@ -228,13 +228,13 @@ process(_, #request{method = 'POST', data = Data, opts = Opts}) ->
end, end,
GetAuth = true, GetAuth = true,
State = #state{access_commands = AccessCommands, get_auth = GetAuth}, State = #state{access_commands = AccessCommands, get_auth = GetAuth},
case xml_stream:parse_element(Data) of case fxml_stream:parse_element(Data) of
{error, _} -> {error, _} ->
{400, [], {400, [],
#xmlel{name = <<"h1">>, attrs = [], #xmlel{name = <<"h1">>, attrs = [],
children = [{xmlcdata, <<"Malformed XML">>}]}}; children = [{xmlcdata, <<"Malformed XML">>}]}};
El -> El ->
case p1_xmlrpc:decode(El) of case fxmlrpc:decode(El) of
{error, _} = Err -> {error, _} = Err ->
?ERROR_MSG("XML-RPC request ~s failed with reason: ~p", ?ERROR_MSG("XML-RPC request ~s failed with reason: ~p",
[Data, Err]), [Data, Err]),
@ -244,7 +244,7 @@ process(_, #request{method = 'POST', data = Data, opts = Opts}) ->
{ok, RPC} -> {ok, RPC} ->
?DEBUG("got XML-RPC request: ~p", [RPC]), ?DEBUG("got XML-RPC request: ~p", [RPC]),
{false, Result} = handler(State, RPC), {false, Result} = handler(State, RPC),
XML = xml:element_to_binary(p1_xmlrpc:encode(Result)), XML = fxml:element_to_binary(fxmlrpc:encode(Result)),
{200, [{<<"Content-Type">>, <<"text/xml">>}], {200, [{<<"Content-Type">>, <<"text/xml">>}],
<<"<?xml version=\"1.0\"?>", XML/binary>>} <<"<?xml version=\"1.0\"?>", XML/binary>>}
end end

View File

@ -48,7 +48,7 @@ import_file(File) ->
true -> true ->
case file:read_file(File) of case file:read_file(File) of
{ok, Text} -> {ok, Text} ->
case xml_stream:parse_element(Text) of case fxml_stream:parse_element(Text) of
El when is_record(El, xmlel) -> El when is_record(El, xmlel) ->
case catch process_xdb(User, Server, El) of case catch process_xdb(User, Server, El) of
{'EXIT', Reason} -> {'EXIT', Reason} ->
@ -113,16 +113,16 @@ process_xdb(User, Server,
xdb_data(_User, _Server, {xmlcdata, _CData}) -> ok; xdb_data(_User, _Server, {xmlcdata, _CData}) -> ok;
xdb_data(User, Server, #xmlel{attrs = Attrs} = El) -> xdb_data(User, Server, #xmlel{attrs = Attrs} = El) ->
From = jid:make(User, Server, <<"">>), From = jid:make(User, Server, <<"">>),
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_AUTH -> ?NS_AUTH ->
Password = xml:get_tag_cdata(El), Password = fxml:get_tag_cdata(El),
ejabberd_auth:set_password(User, Server, Password), ejabberd_auth:set_password(User, Server, Password),
ok; ok;
?NS_ROSTER -> ?NS_ROSTER ->
catch mod_roster:set_items(User, Server, El), ok; catch mod_roster:set_items(User, Server, El), ok;
?NS_LAST -> ?NS_LAST ->
TimeStamp = xml:get_attr_s(<<"last">>, Attrs), TimeStamp = fxml:get_attr_s(<<"last">>, Attrs),
Status = xml:get_tag_cdata(El), Status = fxml:get_tag_cdata(El),
catch mod_last:store_last_info(User, Server, catch mod_last:store_last_info(User, Server,
jlib:binary_to_integer(TimeStamp), jlib:binary_to_integer(TimeStamp),
Status), Status),
@ -136,7 +136,7 @@ xdb_data(User, Server, #xmlel{attrs = Attrs} = El) ->
<<"jabber:x:offline">> -> <<"jabber:x:offline">> ->
process_offline(Server, From, El), ok; process_offline(Server, From, El), ok;
XMLNS -> XMLNS ->
case xml:get_attr_s(<<"j_private_flag">>, Attrs) of case fxml:get_attr_s(<<"j_private_flag">>, Attrs) of
<<"1">> -> <<"1">> ->
catch mod_private:process_sm_iq(From, catch mod_private:process_sm_iq(From,
jid:make(<<"">>, Server, jid:make(<<"">>, Server,
@ -160,7 +160,7 @@ xdb_data(User, Server, #xmlel{attrs = Attrs} = El) ->
process_offline(Server, To, #xmlel{children = Els}) -> process_offline(Server, To, #xmlel{children = Els}) ->
LServer = jid:nameprep(Server), LServer = jid:nameprep(Server),
lists:foreach(fun (#xmlel{attrs = Attrs} = El) -> lists:foreach(fun (#xmlel{attrs = Attrs} = El) ->
FromS = xml:get_attr_s(<<"from">>, Attrs), FromS = fxml:get_attr_s(<<"from">>, Attrs),
From = case FromS of From = case FromS of
<<"">> -> <<"">> ->
jid:make(<<"">>, Server, <<"">>); jid:make(<<"">>, Server, <<"">>);

View File

@ -92,8 +92,8 @@ make_result_iq_reply(#xmlel{name = Name, attrs = Attrs,
-spec make_result_iq_reply_attrs([attr()]) -> [attr()]. -spec make_result_iq_reply_attrs([attr()]) -> [attr()].
make_result_iq_reply_attrs(Attrs) -> make_result_iq_reply_attrs(Attrs) ->
To = xml:get_attr(<<"to">>, Attrs), To = fxml:get_attr(<<"to">>, Attrs),
From = xml:get_attr(<<"from">>, Attrs), From = fxml:get_attr(<<"from">>, Attrs),
Attrs1 = lists:keydelete(<<"to">>, 1, Attrs), Attrs1 = lists:keydelete(<<"to">>, 1, Attrs),
Attrs2 = lists:keydelete(<<"from">>, 1, Attrs1), Attrs2 = lists:keydelete(<<"from">>, 1, Attrs1),
Attrs3 = case To of Attrs3 = case To of
@ -133,8 +133,8 @@ make_error_reply(#xmlel{name = Name, attrs = Attrs,
-spec make_error_reply_attrs([attr()]) -> [attr()]. -spec make_error_reply_attrs([attr()]) -> [attr()].
make_error_reply_attrs(Attrs) -> make_error_reply_attrs(Attrs) ->
To = xml:get_attr(<<"to">>, Attrs), To = fxml:get_attr(<<"to">>, Attrs),
From = xml:get_attr(<<"from">>, Attrs), From = fxml:get_attr(<<"from">>, Attrs),
Attrs1 = lists:keydelete(<<"to">>, 1, Attrs), Attrs1 = lists:keydelete(<<"to">>, 1, Attrs),
Attrs2 = lists:keydelete(<<"from">>, 1, Attrs1), Attrs2 = lists:keydelete(<<"from">>, 1, Attrs1),
Attrs3 = case To of Attrs3 = case To of
@ -159,7 +159,7 @@ make_error_element(Code, Desc) ->
make_correct_from_to_attrs(From, To, Attrs) -> make_correct_from_to_attrs(From, To, Attrs) ->
Attrs1 = lists:keydelete(<<"from">>, 1, Attrs), Attrs1 = lists:keydelete(<<"from">>, 1, Attrs),
Attrs2 = case xml:get_attr(<<"to">>, Attrs) of Attrs2 = case fxml:get_attr(<<"to">>, Attrs) of
{value, _} -> Attrs1; {value, _} -> Attrs1;
_ -> [{<<"to">>, To} | Attrs1] _ -> [{<<"to">>, To} | Attrs1]
end, end,
@ -299,8 +299,8 @@ jid_replace_resource(JID, Resource) ->
-spec get_iq_namespace(xmlel()) -> binary(). -spec get_iq_namespace(xmlel()) -> binary().
get_iq_namespace(#xmlel{name = <<"iq">>, children = Els}) -> get_iq_namespace(#xmlel{name = <<"iq">>, children = Els}) ->
case xml:remove_cdata(Els) of case fxml:remove_cdata(Els) of
[#xmlel{attrs = Attrs}] -> xml:get_attr_s(<<"xmlns">>, Attrs); [#xmlel{attrs = Attrs}] -> fxml:get_attr_s(<<"xmlns">>, Attrs);
_ -> <<"">> _ -> <<"">>
end; end;
get_iq_namespace(_) -> <<"">>. get_iq_namespace(_) -> <<"">>.
@ -326,9 +326,9 @@ iq_query_or_response_info(El) ->
iq_info_internal(El, any). iq_info_internal(El, any).
iq_info_internal(#xmlel{name = <<"iq">>, attrs = Attrs, children = Els}, Filter) -> iq_info_internal(#xmlel{name = <<"iq">>, attrs = Attrs, children = Els}, Filter) ->
ID = xml:get_attr_s(<<"id">>, Attrs), ID = fxml:get_attr_s(<<"id">>, Attrs),
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs), Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
{Type, Class} = case xml:get_attr_s(<<"type">>, Attrs) of {Type, Class} = case fxml:get_attr_s(<<"type">>, Attrs) of
<<"set">> -> {set, request}; <<"set">> -> {set, request};
<<"get">> -> {get, request}; <<"get">> -> {get, request};
<<"result">> -> {result, reply}; <<"result">> -> {result, reply};
@ -336,15 +336,15 @@ iq_info_internal(#xmlel{name = <<"iq">>, attrs = Attrs, children = Els}, Filter)
_ -> {invalid, invalid} _ -> {invalid, invalid}
end, end,
if Type == invalid -> invalid; Class == request; Filter == any -> if Type == invalid -> invalid; Class == request; Filter == any ->
FilteredEls = xml:remove_cdata(Els), FilteredEls = fxml:remove_cdata(Els),
{XMLNS, SubEl} = case {Class, FilteredEls} of {XMLNS, SubEl} = case {Class, FilteredEls} of
{request, [#xmlel{attrs = Attrs2}]} -> {request, [#xmlel{attrs = Attrs2}]} ->
{xml:get_attr_s(<<"xmlns">>, Attrs2), hd(FilteredEls)}; {fxml:get_attr_s(<<"xmlns">>, Attrs2), hd(FilteredEls)};
{reply, _} -> {reply, _} ->
NonErrorEls = [El || #xmlel{name = SubName} = El <- FilteredEls, NonErrorEls = [El || #xmlel{name = SubName} = El <- FilteredEls,
SubName /= <<"error">>], SubName /= <<"error">>],
{case NonErrorEls of {case NonErrorEls of
[NonErrorEl] -> xml:get_tag_attr_s(<<"xmlns">>, NonErrorEl); [NonErrorEl] -> fxml:get_tag_attr_s(<<"xmlns">>, NonErrorEl);
_ -> <<"">> _ -> <<"">>
end, end,
FilteredEls}; FilteredEls};
@ -399,7 +399,7 @@ iq_to_xml(#iq{id = ID, type = Type, sub_el = SubEl}) ->
). ).
parse_xdata_submit(#xmlel{attrs = Attrs, children = Els}) -> parse_xdata_submit(#xmlel{attrs = Attrs, children = Els}) ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"submit">> -> <<"submit">> ->
lists:reverse(parse_xdata_fields(Els, [])); lists:reverse(parse_xdata_fields(Els, []));
<<"form">> -> %% This is a workaround to accept Psi's wrong forms <<"form">> -> %% This is a workaround to accept Psi's wrong forms
@ -418,7 +418,7 @@ parse_xdata_submit(#xmlel{attrs = Attrs, children = Els}) ->
parse_xdata_fields([], Res) -> Res; parse_xdata_fields([], Res) -> Res;
parse_xdata_fields([#xmlel{name = <<"field">>, attrs = Attrs, children = SubEls} parse_xdata_fields([#xmlel{name = <<"field">>, attrs = Attrs, children = SubEls}
| Els], Res) -> | Els], Res) ->
case xml:get_attr_s(<<"var">>, Attrs) of case fxml:get_attr_s(<<"var">>, Attrs) of
<<>> -> <<>> ->
parse_xdata_fields(Els, Res); parse_xdata_fields(Els, Res);
Var -> Var ->
@ -437,7 +437,7 @@ parse_xdata_fields([_ | Els], Res) ->
parse_xdata_values([], Res) -> Res; parse_xdata_values([], Res) -> Res;
parse_xdata_values([#xmlel{name = <<"value">>, children = SubEls} | Els], Res) -> parse_xdata_values([#xmlel{name = <<"value">>, children = SubEls} | Els], Res) ->
Val = xml:get_cdata(SubEls), Val = fxml:get_cdata(SubEls),
parse_xdata_values(Els, [Val | Res]); parse_xdata_values(Els, [Val | Res]);
parse_xdata_values([_ | Els], Res) -> parse_xdata_values([_ | Els], Res) ->
parse_xdata_values(Els, Res). parse_xdata_values(Els, Res).
@ -446,7 +446,7 @@ parse_xdata_values([_ | Els], Res) ->
rsm_decode(#iq{sub_el = SubEl}) -> rsm_decode(SubEl); rsm_decode(#iq{sub_el = SubEl}) -> rsm_decode(SubEl);
rsm_decode(#xmlel{} = SubEl) -> rsm_decode(#xmlel{} = SubEl) ->
case xml:get_subtag(SubEl, <<"set">>) of case fxml:get_subtag(SubEl, <<"set">>) of
false -> none; false -> none;
#xmlel{name = <<"set">>, children = SubEls} -> #xmlel{name = <<"set">>, children = SubEls} ->
lists:foldl(fun rsm_parse_element/2, #rsm_in{}, SubEls) lists:foldl(fun rsm_parse_element/2, #rsm_in{}, SubEls)
@ -455,26 +455,26 @@ rsm_decode(#xmlel{} = SubEl) ->
rsm_parse_element(#xmlel{name = <<"max">>, attrs = []} = rsm_parse_element(#xmlel{name = <<"max">>, attrs = []} =
Elem, Elem,
RsmIn) -> RsmIn) ->
CountStr = xml:get_tag_cdata(Elem), CountStr = fxml:get_tag_cdata(Elem),
{Count, _} = str:to_integer(CountStr), {Count, _} = str:to_integer(CountStr),
RsmIn#rsm_in{max = Count}; RsmIn#rsm_in{max = Count};
rsm_parse_element(#xmlel{name = <<"before">>, rsm_parse_element(#xmlel{name = <<"before">>,
attrs = []} = attrs = []} =
Elem, Elem,
RsmIn) -> RsmIn) ->
UID = xml:get_tag_cdata(Elem), UID = fxml:get_tag_cdata(Elem),
RsmIn#rsm_in{direction = before, id = UID}; RsmIn#rsm_in{direction = before, id = UID};
rsm_parse_element(#xmlel{name = <<"after">>, rsm_parse_element(#xmlel{name = <<"after">>,
attrs = []} = attrs = []} =
Elem, Elem,
RsmIn) -> RsmIn) ->
UID = xml:get_tag_cdata(Elem), UID = fxml:get_tag_cdata(Elem),
RsmIn#rsm_in{direction = aft, id = UID}; RsmIn#rsm_in{direction = aft, id = UID};
rsm_parse_element(#xmlel{name = <<"index">>, rsm_parse_element(#xmlel{name = <<"index">>,
attrs = []} = attrs = []} =
Elem, Elem,
RsmIn) -> RsmIn) ->
IndexStr = xml:get_tag_cdata(Elem), IndexStr = fxml:get_tag_cdata(Elem),
{Index, _} = str:to_integer(IndexStr), {Index, _} = str:to_integer(IndexStr),
RsmIn#rsm_in{index = Index}; RsmIn#rsm_in{index = Index};
rsm_parse_element(_, RsmIn) -> RsmIn. rsm_parse_element(_, RsmIn) -> RsmIn.
@ -535,7 +535,7 @@ is_standalone_chat_state(#xmlel{name = <<"message">>} = El) ->
<<"paused">>], <<"paused">>],
Stripped = Stripped =
lists:foldl(fun(ChatState, AccEl) -> lists:foldl(fun(ChatState, AccEl) ->
xml:remove_subtags(AccEl, ChatState, fxml:remove_subtags(AccEl, ChatState,
{<<"xmlns">>, ?NS_CHATSTATES}) {<<"xmlns">>, ?NS_CHATSTATES})
end, El, ChatStates), end, El, ChatStates),
case Stripped of case Stripped of
@ -558,15 +558,15 @@ add_delay_info(El, From, Time) ->
binary()) -> xmlel(). binary()) -> xmlel().
add_delay_info(El, From, Time, Desc) -> add_delay_info(El, From, Time, Desc) ->
case xml:get_subtag_with_xmlns(El, <<"delay">>, ?NS_DELAY) of case fxml:get_subtag_with_xmlns(El, <<"delay">>, ?NS_DELAY) of
false -> false ->
%% Add new tag %% Add new tag
DelayTag = create_delay_tag(Time, From, Desc), DelayTag = create_delay_tag(Time, From, Desc),
xml:append_subtags(El, [DelayTag]); fxml:append_subtags(El, [DelayTag]);
DelayTag -> DelayTag ->
%% Update existing tag %% Update existing tag
NewDelayTag = NewDelayTag =
case {xml:get_tag_cdata(DelayTag), Desc} of case {fxml:get_tag_cdata(DelayTag), Desc} of
{<<"">>, <<"">>} -> {<<"">>, <<"">>} ->
DelayTag; DelayTag;
{OldDesc, <<"">>} -> {OldDesc, <<"">>} ->
@ -582,8 +582,8 @@ add_delay_info(El, From, Time, Desc) ->
DelayTag#xmlel{children = [{xmlcdata, OldDesc}]} DelayTag#xmlel{children = [{xmlcdata, OldDesc}]}
end end
end, end,
NewEl = xml:remove_subtags(El, <<"delay">>, {<<"xmlns">>, ?NS_DELAY}), NewEl = fxml:remove_subtags(El, <<"delay">>, {<<"xmlns">>, ?NS_DELAY}),
xml:append_subtags(NewEl, [NewDelayTag]) fxml:append_subtags(NewEl, [NewDelayTag])
end. end.
-spec create_delay_tag(erlang:timestamp(), jid() | ljid() | binary(), binary()) -spec create_delay_tag(erlang:timestamp(), jid() | ljid() | binary(), binary())

View File

@ -912,7 +912,7 @@ get_vcard_content(User, Server, Data) ->
[_|_] -> [_|_] ->
case get_vcard(Data, A1) of case get_vcard(Data, A1) of
[false] -> throw(error_no_value_found_in_vcard); [false] -> throw(error_no_value_found_in_vcard);
ElemList -> ?DEBUG("ELS ~p", [ElemList]), [xml:get_tag_cdata(Elem) || Elem <- ElemList] ElemList -> ?DEBUG("ELS ~p", [ElemList]), [fxml:get_tag_cdata(Elem) || Elem <- ElemList]
end; end;
[] -> [] ->
throw(error_no_vcard_found) throw(error_no_vcard_found)
@ -933,7 +933,7 @@ get_vcard([Data], A1) ->
get_subtag(A1, Data). get_subtag(A1, Data).
get_subtag(Xmlelement, Name) -> get_subtag(Xmlelement, Name) ->
[xml:get_subtag(Xmlelement, Name)]. [fxml:get_subtag(Xmlelement, Name)].
set_vcard_content(User, Server, Data, SomeContent) -> set_vcard_content(User, Server, Data, SomeContent) ->
ContentList = case SomeContent of ContentList = case SomeContent of
@ -963,7 +963,7 @@ set_vcard_content(User, Server, Data, SomeContent) ->
take_vcard_tel(TelType, [{xmlel, <<"TEL">>, _, SubEls}=OldEl | OldEls], NewEls, Taken) -> take_vcard_tel(TelType, [{xmlel, <<"TEL">>, _, SubEls}=OldEl | OldEls], NewEls, Taken) ->
{Taken2, NewEls2} = case lists:keymember(TelType, 2, SubEls) of {Taken2, NewEls2} = case lists:keymember(TelType, 2, SubEls) of
true -> {xml:get_subtag(OldEl, <<"NUMBER">>), NewEls}; true -> {fxml:get_subtag(OldEl, <<"NUMBER">>), NewEls};
false -> {Taken, [OldEl | NewEls]} false -> {Taken, [OldEl | NewEls]}
end, end,
take_vcard_tel(TelType, OldEls, NewEls2, Taken2); take_vcard_tel(TelType, OldEls, NewEls2, Taken2);
@ -1206,10 +1206,10 @@ private_get(Username, Host, Element, Ns) ->
[{xmlel, <<"query">>, [{xmlel, <<"query">>,
[{<<"xmlns">>, ?NS_PRIVATE}], [{<<"xmlns">>, ?NS_PRIVATE}],
[SubEl]}] = ResIq#iq.sub_el, [SubEl]}] = ResIq#iq.sub_el,
binary_to_list(xml:element_to_binary(SubEl)). binary_to_list(fxml:element_to_binary(SubEl)).
private_set(Username, Host, ElementString) -> private_set(Username, Host, ElementString) ->
case xml_stream:parse_element(ElementString) of case fxml_stream:parse_element(ElementString) of
{error, Error} -> {error, Error} ->
io:format("Error found parsing the element:~n ~p~nError: ~p~n", io:format("Error found parsing the element:~n ~p~nError: ~p~n",
[ElementString, Error]), [ElementString, Error]),
@ -1333,7 +1333,7 @@ build_packet(Type, Subject, Body) ->
}. }.
send_stanza(FromString, ToString, Stanza) -> send_stanza(FromString, ToString, Stanza) ->
case xml_stream:parse_element(Stanza) of case fxml_stream:parse_element(Stanza) of
{error, Error} -> {error, Error} ->
{error, Error}; {error, Error};
XmlEl -> XmlEl ->
@ -1344,7 +1344,7 @@ send_stanza(FromString, ToString, Stanza) ->
end. end.
send_stanza_c2s(Username, Host, Resource, Stanza) -> send_stanza_c2s(Username, Host, Resource, Stanza) ->
case {xml_stream:parse_element(Stanza), case {fxml_stream:parse_element(Stanza),
ejabberd_sm:get_session_pid(Username, Host, Resource)} ejabberd_sm:get_session_pid(Username, Host, Resource)}
of of
{{error, Error}, _} -> {{error, Error}, _} ->
@ -1358,7 +1358,7 @@ send_stanza_c2s(Username, Host, Resource, Stanza) ->
privacy_set(Username, Host, QueryS) -> privacy_set(Username, Host, QueryS) ->
From = jid:make(Username, Host, <<"">>), From = jid:make(Username, Host, <<"">>),
To = jid:make(<<"">>, Host, <<"">>), To = jid:make(<<"">>, Host, <<"">>),
QueryEl = xml_stream:parse_element(QueryS), QueryEl = fxml_stream:parse_element(QueryS),
StanzaEl = {xmlel, <<"iq">>, [{<<"type">>, <<"set">>}], [QueryEl]}, StanzaEl = {xmlel, <<"iq">>, [{<<"type">>, <<"set">>}], [QueryEl]},
IQ = jlib:iq_query_info(StanzaEl), IQ = jlib:iq_query_info(StanzaEl),
ejabberd_hooks:run_fold( ejabberd_hooks:run_fold(

View File

@ -845,7 +845,7 @@ announce_motd_update(LServer, Packet) ->
packet = Packet}, packet = Packet},
motd_schema())}; motd_schema())};
odbc -> odbc ->
XML = ejabberd_odbc:escape(xml:element_to_binary(Packet)), XML = ejabberd_odbc:escape(fxml:element_to_binary(Packet)),
F = fun() -> F = fun() ->
odbc_queries:update_t( odbc_queries:update_t(
<<"motd">>, <<"motd">>,
@ -953,7 +953,7 @@ send_motd(#jid{luser = LUser, lserver = LServer} = JID, odbc) when LUser /= <<>>
case catch ejabberd_odbc:sql_query( case catch ejabberd_odbc:sql_query(
LServer, [<<"select xml from motd where username='';">>]) of LServer, [<<"select xml from motd where username='';">>]) of
{selected, [<<"xml">>], [[XML]]} -> {selected, [<<"xml">>], [[XML]]} ->
case xml_stream:parse_element(XML) of case fxml_stream:parse_element(XML) of
{error, _} -> {error, _} ->
ok; ok;
Packet -> Packet ->
@ -986,8 +986,8 @@ send_motd(_, odbc) ->
get_stored_motd(LServer) -> get_stored_motd(LServer) ->
case get_stored_motd_packet(LServer, gen_mod:db_type(LServer, ?MODULE)) of case get_stored_motd_packet(LServer, gen_mod:db_type(LServer, ?MODULE)) of
{ok, Packet} -> {ok, Packet} ->
{xml:get_subtag_cdata(Packet, <<"subject">>), {fxml:get_subtag_cdata(Packet, <<"subject">>),
xml:get_subtag_cdata(Packet, <<"body">>)}; fxml:get_subtag_cdata(Packet, <<"body">>)};
error -> error ->
{<<>>, <<>>} {<<>>, <<>>}
end. end.
@ -1010,7 +1010,7 @@ get_stored_motd_packet(LServer, odbc) ->
case catch ejabberd_odbc:sql_query( case catch ejabberd_odbc:sql_query(
LServer, [<<"select xml from motd where username='';">>]) of LServer, [<<"select xml from motd where username='';">>]) of
{selected, [<<"xml">>], [[XML]]} -> {selected, [<<"xml">>], [[XML]]} ->
case xml_stream:parse_element(XML) of case fxml_stream:parse_element(XML) of
{error, _} -> {error, _} ->
error; error;
Packet -> Packet ->
@ -1067,7 +1067,7 @@ update_motd_table() ->
fun(#motd{server = S}) -> S end, fun(#motd{server = S}) -> S end,
fun(#motd{server = S, packet = P} = R) -> fun(#motd{server = S, packet = P} = R) ->
NewS = iolist_to_binary(S), NewS = iolist_to_binary(S),
NewP = xml:to_xmlel(P), NewP = fxml:to_xmlel(P),
R#motd{server = NewS, packet = NewP} R#motd{server = NewS, packet = NewP}
end); end);
_ -> _ ->
@ -1105,7 +1105,7 @@ export(_Server) ->
when LServer == Host -> when LServer == Host ->
[[<<"delete from motd where username='';">>], [[<<"delete from motd where username='';">>],
[<<"insert into motd(username, xml) values ('', '">>, [<<"insert into motd(username, xml) values ('', '">>,
ejabberd_odbc:escape(xml:element_to_binary(El)), ejabberd_odbc:escape(fxml:element_to_binary(El)),
<<"');">>]]; <<"');">>]];
(_Host, _R) -> (_Host, _R) ->
[] []
@ -1124,7 +1124,7 @@ export(_Server) ->
import(LServer) -> import(LServer) ->
[{<<"select xml from motd where username='';">>, [{<<"select xml from motd where username='';">>,
fun([XML]) -> fun([XML]) ->
El = xml_stream:parse_element(XML), El = fxml_stream:parse_element(XML),
#motd{server = LServer, packet = El} #motd{server = LServer, packet = El}
end}, end},
{<<"select username from motd where xml='';">>, {<<"select username from motd where xml='';">>,

View File

@ -76,7 +76,7 @@ process_iq_set(_, From, _To,
sub_el = sub_el =
#xmlel{name = SubElName, children = SubEls}}) -> #xmlel{name = SubElName, children = SubEls}}) ->
#jid{luser = LUser, lserver = LServer} = From, #jid{luser = LUser, lserver = LServer} = From,
Res = case {SubElName, xml:remove_cdata(SubEls)} of Res = case {SubElName, fxml:remove_cdata(SubEls)} of
{<<"block">>, []} -> {error, ?ERR_BAD_REQUEST}; {<<"block">>, []} -> {error, ?ERR_BAD_REQUEST};
{<<"block">>, Els} -> {<<"block">>, Els} ->
JIDs = parse_blocklist_items(Els, []), JIDs = parse_blocklist_items(Els, []),
@ -116,7 +116,7 @@ parse_blocklist_items([#xmlel{name = <<"item">>,
attrs = Attrs} attrs = Attrs}
| Els], | Els],
JIDs) -> JIDs) ->
case xml:get_attr(<<"jid">>, Attrs) of case fxml:get_attr(<<"jid">>, Attrs) of
{value, JID1} -> {value, JID1} ->
JID = jid:tolower(jid:from_string(JID1)), JID = jid:tolower(jid:from_string(JID1)),
parse_blocklist_items(Els, [JID | JIDs]); parse_blocklist_items(Els, [JID | JIDs]);

View File

@ -120,12 +120,12 @@ read_caps(Els) -> read_caps(Els, nothing).
read_caps([#xmlel{name = <<"c">>, attrs = Attrs} read_caps([#xmlel{name = <<"c">>, attrs = Attrs}
| Tail], | Tail],
Result) -> Result) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_CAPS -> ?NS_CAPS ->
Node = xml:get_attr_s(<<"node">>, Attrs), Node = fxml:get_attr_s(<<"node">>, Attrs),
Version = xml:get_attr_s(<<"ver">>, Attrs), Version = fxml:get_attr_s(<<"ver">>, Attrs),
Hash = xml:get_attr_s(<<"hash">>, Attrs), Hash = fxml:get_attr_s(<<"hash">>, Attrs),
Exts = str:tokens(xml:get_attr_s(<<"ext">>, Attrs), Exts = str:tokens(fxml:get_attr_s(<<"ext">>, Attrs),
<<" ">>), <<" ">>),
read_caps(Tail, read_caps(Tail,
#caps{node = Node, hash = Hash, version = Version, #caps{node = Node, hash = Hash, version = Version,
@ -135,7 +135,7 @@ read_caps([#xmlel{name = <<"c">>, attrs = Attrs}
read_caps([#xmlel{name = <<"x">>, attrs = Attrs} read_caps([#xmlel{name = <<"x">>, attrs = Attrs}
| Tail], | Tail],
Result) -> Result) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_MUC_USER -> nothing; ?NS_MUC_USER -> nothing;
_ -> read_caps(Tail, Result) _ -> read_caps(Tail, Result)
end; end;
@ -149,7 +149,7 @@ user_send_packet(#xmlel{name = <<"presence">>, attrs = Attrs,
#jid{luser = User, lserver = Server} = From, #jid{luser = User, lserver = Server} = From,
#jid{luser = User, lserver = Server, #jid{luser = User, lserver = Server,
lresource = <<"">>}) -> lresource = <<"">>}) ->
Type = xml:get_attr_s(<<"type">>, Attrs), Type = fxml:get_attr_s(<<"type">>, Attrs),
if Type == <<"">>; Type == <<"available">> -> if Type == <<"">>; Type == <<"available">> ->
case read_caps(Els) of case read_caps(Els) of
nothing -> ok; nothing -> ok;
@ -167,7 +167,7 @@ user_receive_packet(#xmlel{name = <<"presence">>, attrs = Attrs,
_C2SState, _C2SState,
#jid{lserver = Server}, #jid{lserver = Server},
From, _To) -> From, _To) ->
Type = xml:get_attr_s(<<"type">>, Attrs), Type = fxml:get_attr_s(<<"type">>, Attrs),
IsRemote = not lists:member(From#jid.lserver, ?MYHOSTS), IsRemote = not lists:member(From#jid.lserver, ?MYHOSTS),
if IsRemote and if IsRemote and
((Type == <<"">>) or (Type == <<"available">>)) -> ((Type == <<"">>) or (Type == <<"available">>)) ->
@ -227,7 +227,7 @@ disco_info(Acc, Host, Module, Node, Lang) ->
c2s_presence_in(C2SState, c2s_presence_in(C2SState,
{From, To, {_, _, Attrs, Els}}) -> {From, To, {_, _, Attrs, Els}}) ->
Type = xml:get_attr_s(<<"type">>, Attrs), Type = fxml:get_attr_s(<<"type">>, Attrs),
Subscription = ejabberd_c2s:get_subscription(From, Subscription = ejabberd_c2s:get_subscription(From,
C2SState), C2SState),
Insert = ((Type == <<"">>) or (Type == <<"available">>)) Insert = ((Type == <<"">>) or (Type == <<"available">>))
@ -434,7 +434,7 @@ feature_response(#iq{type = result,
Features = lists:flatmap(fun (#xmlel{name = Features = lists:flatmap(fun (#xmlel{name =
<<"feature">>, <<"feature">>,
attrs = FAttrs}) -> attrs = FAttrs}) ->
[xml:get_attr_s(<<"var">>, FAttrs)]; [fxml:get_attr_s(<<"var">>, FAttrs)];
(_) -> [] (_) -> []
end, end,
Els), Els),
@ -567,7 +567,7 @@ concat_features(Els) ->
lists:usort(lists:flatmap(fun (#xmlel{name = lists:usort(lists:flatmap(fun (#xmlel{name =
<<"feature">>, <<"feature">>,
attrs = Attrs}) -> attrs = Attrs}) ->
[[xml:get_attr_s(<<"var">>, Attrs), $<]]; [[fxml:get_attr_s(<<"var">>, Attrs), $<]];
(_) -> [] (_) -> []
end, end,
Els)). Els)).
@ -576,11 +576,11 @@ concat_identities(Els) ->
lists:sort(lists:flatmap(fun (#xmlel{name = lists:sort(lists:flatmap(fun (#xmlel{name =
<<"identity">>, <<"identity">>,
attrs = Attrs}) -> attrs = Attrs}) ->
[[xml:get_attr_s(<<"category">>, Attrs), [[fxml:get_attr_s(<<"category">>, Attrs),
$/, xml:get_attr_s(<<"type">>, Attrs), $/, fxml:get_attr_s(<<"type">>, Attrs),
$/, $/,
xml:get_attr_s(<<"xml:lang">>, Attrs), fxml:get_attr_s(<<"xml:lang">>, Attrs),
$/, xml:get_attr_s(<<"name">>, Attrs), $/, fxml:get_attr_s(<<"name">>, Attrs),
$<]]; $<]];
(_) -> [] (_) -> []
end, end,
@ -589,8 +589,8 @@ concat_identities(Els) ->
concat_info(Els) -> concat_info(Els) ->
lists:sort(lists:flatmap(fun (#xmlel{name = <<"x">>, lists:sort(lists:flatmap(fun (#xmlel{name = <<"x">>,
attrs = Attrs, children = Fields}) -> attrs = Attrs, children = Fields}) ->
case {xml:get_attr_s(<<"xmlns">>, Attrs), case {fxml:get_attr_s(<<"xmlns">>, Attrs),
xml:get_attr_s(<<"type">>, Attrs)} fxml:get_attr_s(<<"type">>, Attrs)}
of of
{?NS_XDATA, <<"result">>} -> {?NS_XDATA, <<"result">>} ->
[concat_xdata_fields(Fields)]; [concat_xdata_fields(Fields)];
@ -606,10 +606,10 @@ concat_xdata_fields(Fields) ->
attrs = Attrs, children = Els} = attrs = Attrs, children = Els} =
El, El,
[FormType, VarFields] = Acc) -> [FormType, VarFields] = Acc) ->
case xml:get_attr_s(<<"var">>, Attrs) of case fxml:get_attr_s(<<"var">>, Attrs) of
<<"">> -> Acc; <<"">> -> Acc;
<<"FORM_TYPE">> -> <<"FORM_TYPE">> ->
[xml:get_subtag_cdata(El, [fxml:get_subtag_cdata(El,
<<"value">>), <<"value">>),
VarFields]; VarFields];
Var -> Var ->
@ -622,7 +622,7 @@ concat_xdata_fields(Fields) ->
children children
= =
VEls}) -> VEls}) ->
[[xml:get_cdata(VEls), [[fxml:get_cdata(VEls),
$<]]; $<]];
(_) -> (_) ->
[] []

View File

@ -55,9 +55,9 @@ is_carbon_copy(Packet) ->
is_carbon_copy(Packet, <<"received">>). is_carbon_copy(Packet, <<"received">>).
is_carbon_copy(Packet, Direction) -> is_carbon_copy(Packet, Direction) ->
case xml:get_subtag(Packet, Direction) of case fxml:get_subtag(Packet, Direction) of
#xmlel{name = Direction, attrs = Attrs} -> #xmlel{name = Direction, attrs = Attrs} ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_CARBONS_2 -> true; ?NS_CARBONS_2 -> true;
?NS_CARBONS_1 -> true; ?NS_CARBONS_1 -> true;
_ -> false _ -> false
@ -137,8 +137,8 @@ user_receive_packet(Packet, _C2SState, JID, _From, To) ->
% - we also replicate "read" notifications % - we also replicate "read" notifications
check_and_forward(JID, To, Packet, Direction)-> check_and_forward(JID, To, Packet, Direction)->
case is_chat_message(Packet) andalso case is_chat_message(Packet) andalso
xml:get_subtag(Packet, <<"private">>) == false andalso fxml:get_subtag(Packet, <<"private">>) == false andalso
xml:get_subtag(Packet, <<"no-copy">>) == false of fxml:get_subtag(Packet, <<"no-copy">>) == false of
true -> true ->
case is_carbon_copy(Packet) of case is_carbon_copy(Packet) of
false -> false ->
@ -268,7 +268,7 @@ complete_packet(_From, #xmlel{name = <<"message">>, attrs=OrigAttrs} = Packet, r
Packet#xmlel{attrs = Attrs}. Packet#xmlel{attrs = Attrs}.
message_type(#xmlel{attrs = Attrs}) -> message_type(#xmlel{attrs = Attrs}) ->
case xml:get_attr(<<"type">>, Attrs) of case fxml:get_attr(<<"type">>, Attrs) of
{value, Type} -> Type; {value, Type} -> Type;
false -> <<"normal">> false -> <<"normal">>
end. end.
@ -282,7 +282,7 @@ is_chat_message(#xmlel{name = <<"message">>} = Packet) ->
is_chat_message(_Packet) -> false. is_chat_message(_Packet) -> false.
has_non_empty_body(Packet) -> has_non_empty_body(Packet) ->
xml:get_subtag_cdata(Packet, <<"body">>) =/= <<"">>. fxml:get_subtag_cdata(Packet, <<"body">>) =/= <<"">>.
%% list {resource, cc_version} with carbons enabled for given user and host %% list {resource, cc_version} with carbons enabled for given user and host
list(User, Server) -> list(User, Server) ->

View File

@ -80,7 +80,7 @@ add_stream_feature(Features, _Host) ->
[Feature | Features]. [Feature | Features].
filter_presence(_Action, #xmlel{name = <<"presence">>, attrs = Attrs}) -> filter_presence(_Action, #xmlel{name = <<"presence">>, attrs = Attrs}) ->
case xml:get_attr(<<"type">>, Attrs) of case fxml:get_attr(<<"type">>, Attrs) of
{value, Type} when Type /= <<"unavailable">> -> {value, Type} when Type /= <<"unavailable">> ->
?DEBUG("Got important presence stanza", []), ?DEBUG("Got important presence stanza", []),
{stop, send}; {stop, send};

View File

@ -350,7 +350,7 @@ adhoc_local_items(Acc, From,
Nodes = recursively_get_local_items(PermLev, LServer, Nodes = recursively_get_local_items(PermLev, LServer,
<<"">>, Server, Lang), <<"">>, Server, Lang),
Nodes1 = lists:filter(fun (N) -> Nodes1 = lists:filter(fun (N) ->
Nd = xml:get_tag_attr_s(<<"node">>, N), Nd = fxml:get_tag_attr_s(<<"node">>, N),
F = get_local_features([], From, To, Nd, F = get_local_features([], From, To, Nd,
Lang), Lang),
case F of case F of
@ -379,9 +379,9 @@ recursively_get_local_items(PermLev, LServer, Node,
{error, _Error} -> [] {error, _Error} -> []
end, end,
Nodes = lists:flatten(lists:map(fun (N) -> Nodes = lists:flatten(lists:map(fun (N) ->
S = xml:get_tag_attr_s(<<"jid">>, S = fxml:get_tag_attr_s(<<"jid">>,
N), N),
Nd = xml:get_tag_attr_s(<<"node">>, Nd = fxml:get_tag_attr_s(<<"node">>,
N), N),
if (S /= Server) or if (S /= Server) or
(Nd == <<"">>) -> (Nd == <<"">>) ->

View File

@ -65,7 +65,7 @@ process_local_iq(From, To,
set -> set ->
IQ#iq{type = error, IQ#iq{type = error,
sub_el = [SubEl, ?ERR_FEATURE_NOT_IMPLEMENTED]}; sub_el = [SubEl, ?ERR_FEATURE_NOT_IMPLEMENTED]};
%%case xml:get_tag_attr_s("type", SubEl) of %%case fxml:get_tag_attr_s("type", SubEl) of
%% "cancel" -> %% "cancel" ->
%% IQ#iq{type = result, %% IQ#iq{type = result,
%% sub_el = [{xmlelement, "query", %% sub_el = [{xmlelement, "query",
@ -79,7 +79,7 @@ process_local_iq(From, To,
%% _ -> %% _ ->
%% Node = %% Node =
%% string:tokens( %% string:tokens(
%% xml:get_tag_attr_s("node", SubEl), %% fxml:get_tag_attr_s("node", SubEl),
%% "/"), %% "/"),
%% case set_form(Node, Lang, XData) of %% case set_form(Node, Lang, XData) of
%% {result, Res} -> %% {result, Res} ->

View File

@ -152,7 +152,7 @@ process_local_iq_items(From, To,
set -> set ->
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]}; IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]};
get -> get ->
Node = xml:get_tag_attr_s(<<"node">>, SubEl), Node = fxml:get_tag_attr_s(<<"node">>, SubEl),
Host = To#jid.lserver, Host = To#jid.lserver,
case ejabberd_hooks:run_fold(disco_local_items, Host, case ejabberd_hooks:run_fold(disco_local_items, Host,
empty, [From, To, Node, Lang]) empty, [From, To, Node, Lang])
@ -180,7 +180,7 @@ process_local_iq_info(From, To,
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]}; IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]};
get -> get ->
Host = To#jid.lserver, Host = To#jid.lserver,
Node = xml:get_tag_attr_s(<<"node">>, SubEl), Node = fxml:get_tag_attr_s(<<"node">>, SubEl),
Identity = ejabberd_hooks:run_fold(disco_local_identity, Identity = ejabberd_hooks:run_fold(disco_local_identity,
Host, [], [From, To, Node, Lang]), Host, [], [From, To, Node, Lang]),
Info = ejabberd_hooks:run_fold(disco_info, Host, [], Info = ejabberd_hooks:run_fold(disco_info, Host, [],
@ -305,7 +305,7 @@ process_sm_iq_items(From, To,
case is_presence_subscribed(From, To) of case is_presence_subscribed(From, To) of
true -> true ->
Host = To#jid.lserver, Host = To#jid.lserver,
Node = xml:get_tag_attr_s(<<"node">>, SubEl), Node = fxml:get_tag_attr_s(<<"node">>, SubEl),
case ejabberd_hooks:run_fold(disco_sm_items, Host, case ejabberd_hooks:run_fold(disco_sm_items, Host,
empty, [From, To, Node, Lang]) empty, [From, To, Node, Lang])
of of
@ -378,7 +378,7 @@ process_sm_iq_info(From, To,
case is_presence_subscribed(From, To) of case is_presence_subscribed(From, To) of
true -> true ->
Host = To#jid.lserver, Host = To#jid.lserver,
Node = xml:get_tag_attr_s(<<"node">>, SubEl), Node = fxml:get_tag_attr_s(<<"node">>, SubEl),
Identity = ejabberd_hooks:run_fold(disco_sm_identity, Identity = ejabberd_hooks:run_fold(disco_sm_identity,
Host, [], Host, [],
[From, To, Node, Lang]), [From, To, Node, Lang]),

View File

@ -182,7 +182,7 @@ do_client_version(enabled, From, To) ->
Els = receive Els = receive
{route, To, From2, IQ} -> {route, To, From2, IQ} ->
#xmlel{name = <<"query">>, children = List} = #xmlel{name = <<"query">>, children = List} =
xml:get_subtag(IQ, <<"query">>), fxml:get_subtag(IQ, <<"query">>),
List List
after 5000 -> % Timeout in miliseconds: 5 seconds after 5000 -> % Timeout in miliseconds: 5 seconds
[] []

View File

@ -572,12 +572,12 @@ process_iq(_From, invalid, _State) ->
-> {ok, binary(), pos_integer(), binary()} | {error, xmlel()}. -> {ok, binary(), pos_integer(), binary()} | {error, xmlel()}.
parse_request(#xmlel{name = <<"request">>, attrs = Attrs} = Request, Lang) -> parse_request(#xmlel{name = <<"request">>, attrs = Attrs} = Request, Lang) ->
case xml:get_attr(<<"xmlns">>, Attrs) of case fxml:get_attr(<<"xmlns">>, Attrs) of
{value, XMLNS} when XMLNS == ?NS_HTTP_UPLOAD; {value, XMLNS} when XMLNS == ?NS_HTTP_UPLOAD;
XMLNS == ?NS_HTTP_UPLOAD_OLD -> XMLNS == ?NS_HTTP_UPLOAD_OLD ->
case {xml:get_subtag_cdata(Request, <<"filename">>), case {fxml:get_subtag_cdata(Request, <<"filename">>),
xml:get_subtag_cdata(Request, <<"size">>), fxml:get_subtag_cdata(Request, <<"size">>),
xml:get_subtag_cdata(Request, <<"content-type">>)} of fxml:get_subtag_cdata(Request, <<"content-type">>)} of
{File, SizeStr, ContentType} when byte_size(File) > 0 -> {File, SizeStr, ContentType} when byte_size(File) > 0 ->
case catch jlib:binary_to_integer(SizeStr) of case catch jlib:binary_to_integer(SizeStr) of
Size when is_integer(Size), Size > 0 -> Size when is_integer(Size), Size > 0 ->
@ -796,7 +796,7 @@ store_file(Path, Data, FileMode, DirMode, GetPrefix, Slot, Thumbnail) ->
{ok, {ok,
[{<<"Content-Type">>, [{<<"Content-Type">>,
<<"text/xml; charset=utf-8">>}], <<"text/xml; charset=utf-8">>}],
xml:element_to_binary(ThumbEl)}; fxml:element_to_binary(ThumbEl)};
pass -> pass ->
ok ok
end; end;

View File

@ -216,7 +216,7 @@ do_route(Host, ServerHost, Access, From, To, Packet) ->
allow -> do_route1(Host, ServerHost, From, To, Packet); allow -> do_route1(Host, ServerHost, From, To, Packet);
_ -> _ ->
#xmlel{attrs = Attrs} = Packet, #xmlel{attrs = Attrs} = Packet,
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs), Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
ErrText = <<"Access denied by service policy">>, ErrText = <<"Access denied by service policy">>,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_FORBIDDEN(Lang, ErrText)), ?ERRT_FORBIDDEN(Lang, ErrText)),
@ -234,7 +234,7 @@ do_route1(Host, ServerHost, From, To, Packet) ->
#iq{type = get, xmlns = (?NS_DISCO_INFO) = XMLNS, #iq{type = get, xmlns = (?NS_DISCO_INFO) = XMLNS,
sub_el = SubEl, lang = Lang} = sub_el = SubEl, lang = Lang} =
IQ -> IQ ->
Node = xml:get_tag_attr_s(<<"node">>, SubEl), Node = fxml:get_tag_attr_s(<<"node">>, SubEl),
Info = ejabberd_hooks:run_fold(disco_info, ServerHost, Info = ejabberd_hooks:run_fold(disco_info, ServerHost,
[], [],
[ServerHost, ?MODULE, [ServerHost, ?MODULE,
@ -262,7 +262,7 @@ do_route1(Host, ServerHost, From, To, Packet) ->
#iq{type = get, xmlns = (?NS_DISCO_ITEMS) = XMLNS, #iq{type = get, xmlns = (?NS_DISCO_ITEMS) = XMLNS,
sub_el = SubEl, lang = Lang} = sub_el = SubEl, lang = Lang} =
IQ -> IQ ->
Node = xml:get_tag_attr_s(<<"node">>, SubEl), Node = fxml:get_tag_attr_s(<<"node">>, SubEl),
case Node of case Node of
<<>> -> <<>> ->
ResIQ = IQ#iq{type = result, ResIQ = IQ#iq{type = result,
@ -516,7 +516,7 @@ find_xdata_el1([]) -> false;
find_xdata_el1([#xmlel{name = Name, attrs = Attrs, find_xdata_el1([#xmlel{name = Name, attrs = Attrs,
children = SubEls} children = SubEls}
| Els]) -> | Els]) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_XDATA -> ?NS_XDATA ->
#xmlel{name = Name, attrs = Attrs, children = SubEls}; #xmlel{name = Name, attrs = Attrs, children = SubEls};
_ -> find_xdata_el1(Els) _ -> find_xdata_el1(Els)
@ -535,7 +535,7 @@ process_irc_register(ServerHost, Host, From, _To,
IQ#iq{type = error, IQ#iq{type = error,
sub_el = [SubEl, ?ERR_NOT_ACCEPTABLE]}; sub_el = [SubEl, ?ERR_NOT_ACCEPTABLE]};
#xmlel{attrs = Attrs} -> #xmlel{attrs = Attrs} ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"cancel">> -> <<"cancel">> ->
IQ#iq{type = result, IQ#iq{type = result,
sub_el = sub_el =
@ -549,7 +549,7 @@ process_irc_register(ServerHost, Host, From, _To,
IQ#iq{type = error, IQ#iq{type = error,
sub_el = [SubEl, ?ERR_BAD_REQUEST]}; sub_el = [SubEl, ?ERR_BAD_REQUEST]};
_ -> _ ->
Node = str:tokens(xml:get_tag_attr_s(<<"node">>, Node = str:tokens(fxml:get_tag_attr_s(<<"node">>,
SubEl), SubEl),
<<"/">>), <<"/">>),
case set_form(ServerHost, Host, From, Node, Lang, case set_form(ServerHost, Host, From, Node, Lang,
@ -571,7 +571,7 @@ process_irc_register(ServerHost, Host, From, _To,
end end
end; end;
get -> get ->
Node = str:tokens(xml:get_tag_attr_s(<<"node">>, SubEl), Node = str:tokens(fxml:get_tag_attr_s(<<"node">>, SubEl),
<<"/">>), <<"/">>),
case get_form(ServerHost, Host, From, Node, Lang) of case get_form(ServerHost, Host, From, Node, Lang) of
{result, Res} -> {result, Res} ->
@ -1368,7 +1368,7 @@ mod_opt_type(_) ->
[access, db_type, default_encoding, host]. [access, db_type, default_encoding, host].
extract_ident(Packet) -> extract_ident(Packet) ->
case xml:get_subtag(Packet, <<"headers">>) of case fxml:get_subtag(Packet, <<"headers">>) of
{xmlel, _Name, _Attrs, Headers} -> {xmlel, _Name, _Attrs, Headers} ->
extract_header(<<"X-Irc-Ident">>, Headers); extract_header(<<"X-Irc-Ident">>, Headers);
_ -> _ ->
@ -1376,7 +1376,7 @@ extract_ident(Packet) ->
end. end.
extract_ip_address(Packet) -> extract_ip_address(Packet) ->
case xml:get_subtag(Packet, <<"headers">>) of case fxml:get_subtag(Packet, <<"headers">>) of
{xmlel, _Name, _Attrs, Headers} -> {xmlel, _Name, _Attrs, Headers} ->
extract_header(<<"X-Forwarded-For">>, Headers); extract_header(<<"X-Forwarded-For">>, Headers);
_ -> _ ->
@ -1384,7 +1384,7 @@ extract_ip_address(Packet) ->
end. end.
extract_header(HeaderName, [{xmlel, _Name, _Attrs, [{xmlcdata, Value}]} | Tail]) -> extract_header(HeaderName, [{xmlel, _Name, _Attrs, [{xmlcdata, Value}]} | Tail]) ->
case xml:get_attr(<<"name">>, _Attrs) of case fxml:get_attr(<<"name">>, _Attrs) of
{value, HeaderName} -> {value, HeaderName} ->
binary_to_list(Value); binary_to_list(Value);
_ -> _ ->

View File

@ -233,7 +233,7 @@ get_password_from_presence(#xmlel{name = <<"presence">>,
case lists:filter(fun (El) -> case lists:filter(fun (El) ->
case El of case El of
#xmlel{name = <<"x">>, attrs = Attrs} -> #xmlel{name = <<"x">>, attrs = Attrs} ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_MUC -> true; ?NS_MUC -> true;
_ -> false _ -> false
end; end;
@ -243,9 +243,9 @@ get_password_from_presence(#xmlel{name = <<"presence">>,
Els) Els)
of of
[ElXMUC | _] -> [ElXMUC | _] ->
case xml:get_subtag(ElXMUC, <<"password">>) of case fxml:get_subtag(ElXMUC, <<"password">>) of
#xmlel{name = <<"password">>} = PasswordTag -> #xmlel{name = <<"password">>} = PasswordTag ->
{true, xml:get_tag_cdata(PasswordTag)}; {true, fxml:get_tag_cdata(PasswordTag)};
_ -> false _ -> false
end; end;
_ -> false _ -> false
@ -261,7 +261,7 @@ handle_info({route_chan, Channel, Resource,
#xmlel{name = <<"presence">>, attrs = Attrs} = #xmlel{name = <<"presence">>, attrs = Attrs} =
Presence}, Presence},
StateName, StateData) -> StateName, StateData) ->
NewStateData = case xml:get_attr_s(<<"type">>, Attrs) of NewStateData = case fxml:get_attr_s(<<"type">>, Attrs) of
<<"unavailable">> -> <<"unavailable">> ->
send_stanza_unavailable(Channel, StateData), send_stanza_unavailable(Channel, StateData),
S1 = (?SEND((io_lib:format("PART #~s\r\n", S1 = (?SEND((io_lib:format("PART #~s\r\n",
@ -312,9 +312,9 @@ handle_info({route_chan, Channel, Resource,
handle_info({route_chan, Channel, Resource, handle_info({route_chan, Channel, Resource,
#xmlel{name = <<"message">>, attrs = Attrs} = El}, #xmlel{name = <<"message">>, attrs = Attrs} = El},
StateName, StateData) -> StateName, StateData) ->
NewStateData = case xml:get_attr_s(<<"type">>, Attrs) of NewStateData = case fxml:get_attr_s(<<"type">>, Attrs) of
<<"groupchat">> -> <<"groupchat">> ->
case xml:get_path_s(El, [{elem, <<"subject">>}, cdata]) case fxml:get_path_s(El, [{elem, <<"subject">>}, cdata])
of of
<<"">> -> <<"">> ->
ejabberd_router:route( ejabberd_router:route(
@ -325,7 +325,7 @@ handle_info({route_chan, Channel, Resource,
StateData#state.host, StateData#state.host,
StateData#state.nick), StateData#state.nick),
StateData#state.user, El), StateData#state.user, El),
Body = xml:get_path_s(El, Body = fxml:get_path_s(El,
[{elem, <<"body">>}, [{elem, <<"body">>},
cdata]), cdata]),
case Body of case Body of
@ -386,7 +386,7 @@ handle_info({route_chan, Channel, Resource,
when Type == <<"chat">>; when Type == <<"chat">>;
Type == <<"">>; Type == <<"">>;
Type == <<"normal">> -> Type == <<"normal">> ->
Body = xml:get_path_s(El, [{elem, <<"body">>}, cdata]), Body = fxml:get_path_s(El, [{elem, <<"body">>}, cdata]),
case Body of case Body of
<<"/quote ", Rest/binary>> -> <<"/quote ", Rest/binary>> ->
?SEND(<<Rest/binary, "\r\n">>); ?SEND(<<Rest/binary, "\r\n">>);
@ -481,9 +481,9 @@ handle_info({route_chan, _Channel, _Resource, _Packet},
handle_info({route_nick, Nick, handle_info({route_nick, Nick,
#xmlel{name = <<"message">>, attrs = Attrs} = El}, #xmlel{name = <<"message">>, attrs = Attrs} = El},
StateName, StateData) -> StateName, StateData) ->
NewStateData = case xml:get_attr_s(<<"type">>, Attrs) of NewStateData = case fxml:get_attr_s(<<"type">>, Attrs) of
<<"chat">> -> <<"chat">> ->
Body = xml:get_path_s(El, [{elem, <<"body">>}, cdata]), Body = fxml:get_path_s(El, [{elem, <<"body">>}, cdata]),
case Body of case Body of
<<"/quote ", Rest/binary>> -> <<"/quote ", Rest/binary>> ->
?SEND(<<Rest/binary, "\r\n">>); ?SEND(<<Rest/binary, "\r\n">>);
@ -778,13 +778,13 @@ bounce_messages(Reason) ->
receive receive
{send_element, El} -> {send_element, El} ->
#xmlel{attrs = Attrs} = El, #xmlel{attrs = Attrs} = El,
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"error">> -> ok; <<"error">> -> ok;
_ -> _ ->
Err = jlib:make_error_reply(El, <<"502">>, Reason), Err = jlib:make_error_reply(El, <<"502">>, Reason),
From = jid:from_string(xml:get_attr_s(<<"from">>, From = jid:from_string(fxml:get_attr_s(<<"from">>,
Attrs)), Attrs)),
To = jid:from_string(xml:get_attr_s(<<"to">>, To = jid:from_string(fxml:get_attr_s(<<"to">>,
Attrs)), Attrs)),
ejabberd_router:route(To, From, Err) ejabberd_router:route(To, From, Err)
end, end,
@ -1535,14 +1535,14 @@ iq_admin(StateData, Channel, From, To,
end. end.
process_iq_admin(StateData, Channel, set, SubEl) -> process_iq_admin(StateData, Channel, set, SubEl) ->
case xml:get_subtag(SubEl, <<"item">>) of case fxml:get_subtag(SubEl, <<"item">>) of
false -> {error, ?ERR_BAD_REQUEST}; false -> {error, ?ERR_BAD_REQUEST};
ItemEl -> ItemEl ->
Nick = xml:get_tag_attr_s(<<"nick">>, ItemEl), Nick = fxml:get_tag_attr_s(<<"nick">>, ItemEl),
Affiliation = xml:get_tag_attr_s(<<"affiliation">>, Affiliation = fxml:get_tag_attr_s(<<"affiliation">>,
ItemEl), ItemEl),
Role = xml:get_tag_attr_s(<<"role">>, ItemEl), Role = fxml:get_tag_attr_s(<<"role">>, ItemEl),
Reason = xml:get_path_s(ItemEl, Reason = fxml:get_path_s(ItemEl,
[{elem, <<"reason">>}, cdata]), [{elem, <<"reason">>}, cdata]),
process_admin(StateData, Channel, Nick, Affiliation, process_admin(StateData, Channel, Nick, Affiliation,
Role, Reason) Role, Reason)

View File

@ -287,7 +287,7 @@ muc_process_iq(#iq{type = set,
sub_el = #xmlel{name = <<"query">>, sub_el = #xmlel{name = <<"query">>,
attrs = Attrs} = SubEl} = IQ, attrs = Attrs} = SubEl} = IQ,
MUCState, From, To) -> MUCState, From, To) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
NS when NS == ?NS_MAM_0; NS == ?NS_MAM_1 -> NS when NS == ?NS_MAM_0; NS == ?NS_MAM_1 ->
muc_process_iq(IQ, MUCState, From, To, get_xdata_fields(SubEl)); muc_process_iq(IQ, MUCState, From, To, get_xdata_fields(SubEl));
_ -> _ ->
@ -297,7 +297,7 @@ muc_process_iq(#iq{type = get,
sub_el = #xmlel{name = <<"query">>, sub_el = #xmlel{name = <<"query">>,
attrs = Attrs} = SubEl} = IQ, attrs = Attrs} = SubEl} = IQ,
MUCState, From, To) -> MUCState, From, To) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_MAM_TMP -> ?NS_MAM_TMP ->
muc_process_iq(IQ, MUCState, From, To, parse_query_v0_2(SubEl)); muc_process_iq(IQ, MUCState, From, To, parse_query_v0_2(SubEl));
NS when NS == ?NS_MAM_0; NS == ?NS_MAM_1 -> NS when NS == ?NS_MAM_0; NS == ?NS_MAM_1 ->
@ -310,8 +310,8 @@ muc_process_iq(IQ, _MUCState, _From, _To) ->
IQ. IQ.
get_xdata_fields(SubEl) -> get_xdata_fields(SubEl) ->
case {xml:get_subtag_with_xmlns(SubEl, <<"x">>, ?NS_XDATA), case {fxml:get_subtag_with_xmlns(SubEl, <<"x">>, ?NS_XDATA),
xml:get_subtag_with_xmlns(SubEl, <<"set">>, ?NS_RSM)} of fxml:get_subtag_with_xmlns(SubEl, <<"set">>, ?NS_RSM)} of
{#xmlel{} = XData, false} -> {#xmlel{} = XData, false} ->
jlib:parse_xdata_submit(XData); jlib:parse_xdata_submit(XData);
{#xmlel{} = XData, #xmlel{}} -> {#xmlel{} = XData, #xmlel{}} ->
@ -407,7 +407,7 @@ delete_old_messages(_TimeStamp, _Type, _Host, _DBType) ->
%%%=================================================================== %%%===================================================================
process_iq(LServer, #iq{sub_el = #xmlel{attrs = Attrs}} = IQ) -> process_iq(LServer, #iq{sub_el = #xmlel{attrs = Attrs}} = IQ) ->
NS = case xml:get_attr_s(<<"xmlns">>, Attrs) of NS = case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_MAM_0 -> ?NS_MAM_0 ->
?NS_MAM_0; ?NS_MAM_0;
_ -> _ ->
@ -448,7 +448,7 @@ process_iq(LServer, #iq{sub_el = #xmlel{attrs = Attrs}} = IQ) ->
process_iq(#jid{luser = LUser, lserver = LServer}, process_iq(#jid{luser = LUser, lserver = LServer},
#jid{lserver = LServer}, #jid{lserver = LServer},
#iq{type = set, sub_el = #xmlel{name = <<"prefs">>} = SubEl} = IQ) -> #iq{type = set, sub_el = #xmlel{name = <<"prefs">>} = SubEl} = IQ) ->
try {case xml:get_tag_attr_s(<<"default">>, SubEl) of try {case fxml:get_tag_attr_s(<<"default">>, SubEl) of
<<"always">> -> always; <<"always">> -> always;
<<"never">> -> never; <<"never">> -> never;
<<"roster">> -> roster <<"roster">> -> roster
@ -524,7 +524,7 @@ process_iq(LServer, #jid{luser = LUser} = From, To, IQ, SubEl, Fs, MsgType) ->
{_Start, _End, _With, #rsm_in{index = Index}} when is_integer(Index) -> {_Start, _End, _With, #rsm_in{index = Index}} when is_integer(Index) ->
IQ#iq{type = error, sub_el = [SubEl, ?ERR_FEATURE_NOT_IMPLEMENTED]}; IQ#iq{type = error, sub_el = [SubEl, ?ERR_FEATURE_NOT_IMPLEMENTED]};
{Start, End, With, RSM} -> {Start, End, With, RSM} ->
NS = xml:get_tag_attr_s(<<"xmlns">>, SubEl), NS = fxml:get_tag_attr_s(<<"xmlns">>, SubEl),
select_and_send(LServer, From, To, Start, End, select_and_send(LServer, From, To, Start, End,
With, limit_max(RSM, NS), IQ, MsgType) With, limit_max(RSM, NS), IQ, MsgType)
end. end.
@ -548,13 +548,13 @@ muc_process_iq(#iq{lang = Lang, sub_el = SubEl} = IQ,
parse_query_v0_2(Query) -> parse_query_v0_2(Query) ->
lists:flatmap( lists:flatmap(
fun (#xmlel{name = <<"start">>} = El) -> fun (#xmlel{name = <<"start">>} = El) ->
[{<<"start">>, [xml:get_tag_cdata(El)]}]; [{<<"start">>, [fxml:get_tag_cdata(El)]}];
(#xmlel{name = <<"end">>} = El) -> (#xmlel{name = <<"end">>} = El) ->
[{<<"end">>, [xml:get_tag_cdata(El)]}]; [{<<"end">>, [fxml:get_tag_cdata(El)]}];
(#xmlel{name = <<"with">>} = El) -> (#xmlel{name = <<"with">>} = El) ->
[{<<"with">>, [xml:get_tag_cdata(El)]}]; [{<<"with">>, [fxml:get_tag_cdata(El)]}];
(#xmlel{name = <<"withtext">>} = El) -> (#xmlel{name = <<"withtext">>} = El) ->
[{<<"withtext">>, [xml:get_tag_cdata(El)]}]; [{<<"withtext">>, [fxml:get_tag_cdata(El)]}];
(#xmlel{name = <<"set">>}) -> (#xmlel{name = <<"set">>}) ->
[{<<"set">>, Query}]; [{<<"set">>, Query}];
(_) -> (_) ->
@ -562,7 +562,7 @@ parse_query_v0_2(Query) ->
end, Query#xmlel.children). end, Query#xmlel.children).
should_archive(#xmlel{name = <<"message">>} = Pkt, LServer) -> should_archive(#xmlel{name = <<"message">>} = Pkt, LServer) ->
case xml:get_attr_s(<<"type">>, Pkt#xmlel.attrs) of case fxml:get_attr_s(<<"type">>, Pkt#xmlel.attrs) of
<<"error">> -> <<"error">> ->
false; false;
<<"groupchat">> -> <<"groupchat">> ->
@ -578,7 +578,7 @@ should_archive(#xmlel{name = <<"message">>} = Pkt, LServer) ->
no_store -> no_store ->
false; false;
none -> none ->
case xml:get_subtag_cdata(Pkt, <<"body">>) of case fxml:get_subtag_cdata(Pkt, <<"body">>) of
<<>> -> <<>> ->
%% Empty body %% Empty body
false; false;
@ -596,7 +596,7 @@ strip_my_archived_tag(Pkt, LServer) ->
fun(#xmlel{name = Tag, attrs = Attrs}) fun(#xmlel{name = Tag, attrs = Attrs})
when Tag == <<"archived">>; Tag == <<"stanza-id">> -> when Tag == <<"archived">>; Tag == <<"stanza-id">> ->
case catch jid:nameprep( case catch jid:nameprep(
xml:get_attr_s( fxml:get_attr_s(
<<"by">>, Attrs)) of <<"by">>, Attrs)) of
LServer -> LServer ->
false; false;
@ -612,9 +612,9 @@ strip_x_jid_tags(Pkt) ->
NewEls = lists:filter( NewEls = lists:filter(
fun(#xmlel{name = <<"x">>} = XEl) -> fun(#xmlel{name = <<"x">>} = XEl) ->
not lists:any(fun(ItemEl) -> not lists:any(fun(ItemEl) ->
xml:get_tag_attr(<<"jid">>, ItemEl) fxml:get_tag_attr(<<"jid">>, ItemEl)
/= false /= false
end, xml:get_subtags(XEl, <<"item">>)); end, fxml:get_subtags(XEl, <<"item">>));
(_) -> (_) ->
true true
end, Pkt#xmlel.children), end, Pkt#xmlel.children),
@ -650,7 +650,7 @@ should_archive_peer(C2SState,
end. end.
should_archive_muc(Pkt) -> should_archive_muc(Pkt) ->
case xml:get_attr_s(<<"type">>, Pkt#xmlel.attrs) of case fxml:get_attr_s(<<"type">>, Pkt#xmlel.attrs) of
<<"groupchat">> -> <<"groupchat">> ->
case check_store_hint(Pkt) of case check_store_hint(Pkt) of
store -> store ->
@ -658,9 +658,9 @@ should_archive_muc(Pkt) ->
no_store -> no_store ->
false; false;
none -> none ->
case xml:get_subtag_cdata(Pkt, <<"body">>) of case fxml:get_subtag_cdata(Pkt, <<"body">>) of
<<>> -> <<>> ->
case xml:get_subtag_cdata(Pkt, <<"subject">>) of case fxml:get_subtag_cdata(Pkt, <<"subject">>) of
<<>> -> <<>> ->
false; false;
_ -> _ ->
@ -688,23 +688,23 @@ check_store_hint(Pkt) ->
end. end.
has_store_hint(Message) -> has_store_hint(Message) ->
xml:get_subtag_with_xmlns(Message, <<"store">>, ?NS_HINTS) fxml:get_subtag_with_xmlns(Message, <<"store">>, ?NS_HINTS)
/= false. /= false.
has_no_store_hint(Message) -> has_no_store_hint(Message) ->
xml:get_subtag_with_xmlns(Message, <<"no-store">>, ?NS_HINTS) fxml:get_subtag_with_xmlns(Message, <<"no-store">>, ?NS_HINTS)
/= false orelse /= false orelse
xml:get_subtag_with_xmlns(Message, <<"no-storage">>, ?NS_HINTS) fxml:get_subtag_with_xmlns(Message, <<"no-storage">>, ?NS_HINTS)
/= false orelse /= false orelse
xml:get_subtag_with_xmlns(Message, <<"no-permanent-store">>, ?NS_HINTS) fxml:get_subtag_with_xmlns(Message, <<"no-permanent-store">>, ?NS_HINTS)
/= false orelse /= false orelse
xml:get_subtag_with_xmlns(Message, <<"no-permanent-storage">>, ?NS_HINTS) fxml:get_subtag_with_xmlns(Message, <<"no-permanent-storage">>, ?NS_HINTS)
/= false. /= false.
is_resent(Pkt, LServer) -> is_resent(Pkt, LServer) ->
case xml:get_subtag_with_xmlns(Pkt, <<"stanza-id">>, ?NS_SID_0) of case fxml:get_subtag_with_xmlns(Pkt, <<"stanza-id">>, ?NS_SID_0) of
#xmlel{attrs = Attrs} -> #xmlel{attrs = Attrs} ->
case xml:get_attr(<<"by">>, Attrs) of case fxml:get_attr(<<"by">>, Attrs) of
{value, LServer} -> {value, LServer} ->
true; true;
_ -> _ ->
@ -766,8 +766,8 @@ store(Pkt, LServer, {LUser, LHost}, Type, Peer, Nick, _Dir, odbc) ->
jid:remove_resource(Peer))), jid:remove_resource(Peer))),
LPeer = jid:to_string( LPeer = jid:to_string(
jid:tolower(Peer)), jid:tolower(Peer)),
XML = xml:element_to_binary(Pkt), XML = fxml:element_to_binary(Pkt),
Body = xml:get_subtag_cdata(Pkt, <<"body">>), Body = fxml:get_subtag_cdata(Pkt, <<"body">>),
case ejabberd_odbc:sql_query( case ejabberd_odbc:sql_query(
LServer, LServer,
[<<"insert into archive (username, timestamp, " [<<"insert into archive (username, timestamp, "
@ -1005,7 +1005,7 @@ select(LServer, #jid{luser = LUser} = JidRequestor,
{lists:flatmap( {lists:flatmap(
fun([TS, XML, PeerBin, Kind, Nick]) -> fun([TS, XML, PeerBin, Kind, Nick]) ->
try try
#xmlel{} = El = xml_stream:parse_element(XML), #xmlel{} = El = fxml_stream:parse_element(XML),
Now = usec_to_now(jlib:binary_to_integer(TS)), Now = usec_to_now(jlib:binary_to_integer(TS)),
PeerJid = jid:tolower(jid:from_string(PeerBin)), PeerJid = jid:tolower(jid:from_string(PeerBin)),
T = case Kind of T = case Kind of
@ -1039,7 +1039,7 @@ msg_to_el(#archive_msg{timestamp = TS, packet = Pkt1, nick = Nick, peer = Peer},
Pkt2 = maybe_update_from_to(Pkt1, JidRequestor, Peer, MsgType, Nick), Pkt2 = maybe_update_from_to(Pkt1, JidRequestor, Peer, MsgType, Nick),
Pkt3 = #xmlel{name = <<"forwarded">>, Pkt3 = #xmlel{name = <<"forwarded">>,
attrs = [{<<"xmlns">>, ?NS_FORWARD}], attrs = [{<<"xmlns">>, ?NS_FORWARD}],
children = [xml:replace_tag_attr( children = [fxml:replace_tag_attr(
<<"xmlns">>, <<"jabber:client">>, Pkt2)]}, <<"xmlns">>, <<"jabber:client">>, Pkt2)]},
jlib:add_delay_info(Pkt3, LServer, TS). jlib:add_delay_info(Pkt3, LServer, TS).
@ -1095,8 +1095,8 @@ is_bare_copy(#jid{luser = U, lserver = S, lresource = R}, To) ->
end. end.
send(From, To, Msgs, RSM, Count, IsComplete, #iq{sub_el = SubEl} = IQ) -> send(From, To, Msgs, RSM, Count, IsComplete, #iq{sub_el = SubEl} = IQ) ->
QID = xml:get_tag_attr_s(<<"queryid">>, SubEl), QID = fxml:get_tag_attr_s(<<"queryid">>, SubEl),
NS = xml:get_tag_attr_s(<<"xmlns">>, SubEl), NS = fxml:get_tag_attr_s(<<"xmlns">>, SubEl),
QIDAttr = if QID /= <<>> -> QIDAttr = if QID /= <<>> ->
[{<<"queryid">>, QID}]; [{<<"queryid">>, QID}];
true -> true ->
@ -1336,7 +1336,7 @@ datetime_to_now(DateTime, USecs) ->
get_jids(Els) -> get_jids(Els) ->
lists:flatmap( lists:flatmap(
fun(#xmlel{name = <<"jid">>} = El) -> fun(#xmlel{name = <<"jid">>} = El) ->
J = jid:from_string(xml:get_tag_cdata(El)), J = jid:from_string(fxml:get_tag_cdata(El)),
[jid:tolower(jid:remove_resource(J)), [jid:tolower(jid:remove_resource(J)),
jid:tolower(J)]; jid:tolower(J)];
(_) -> (_) ->

View File

@ -222,7 +222,7 @@ remove_room_mam(LServer, Host, Name) ->
process_iq_disco_items(Host, From, To, process_iq_disco_items(Host, From, To,
#iq{lang = Lang} = IQ) -> #iq{lang = Lang} = IQ) ->
Rsm = jlib:rsm_decode(IQ), Rsm = jlib:rsm_decode(IQ),
DiscoNode = xml:get_tag_attr_s(<<"node">>, IQ#iq.sub_el), DiscoNode = fxml:get_tag_attr_s(<<"node">>, IQ#iq.sub_el),
Res = IQ#iq{type = result, Res = IQ#iq{type = result,
sub_el = sub_el =
[#xmlel{name = <<"query">>, [#xmlel{name = <<"query">>,
@ -451,7 +451,7 @@ do_route(Host, ServerHost, Access, HistorySize, RoomShaper,
From, To, Packet, DefRoomOpts); From, To, Packet, DefRoomOpts);
_ -> _ ->
#xmlel{attrs = Attrs} = Packet, #xmlel{attrs = Attrs} = Packet,
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs), Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
ErrText = <<"Access denied by service policy">>, ErrText = <<"Access denied by service policy">>,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_FORBIDDEN(Lang, ErrText)), ?ERRT_FORBIDDEN(Lang, ErrText)),
@ -557,18 +557,18 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
_ -> ok _ -> ok
end; end;
<<"message">> -> <<"message">> ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"error">> -> ok; <<"error">> -> ok;
_ -> _ ->
case acl:match_rule(ServerHost, AccessAdmin, From) case acl:match_rule(ServerHost, AccessAdmin, From)
of of
allow -> allow ->
Msg = xml:get_path_s(Packet, Msg = fxml:get_path_s(Packet,
[{elem, <<"body">>}, [{elem, <<"body">>},
cdata]), cdata]),
broadcast_service_message(Host, Msg); broadcast_service_message(Host, Msg);
_ -> _ ->
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs), Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
ErrText = ErrText =
<<"Only service administrators are allowed " <<"Only service administrators are allowed "
"to send service messages">>, "to send service messages">>,
@ -581,7 +581,7 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
<<"presence">> -> ok <<"presence">> -> ok
end; end;
_ -> _ ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"error">> -> ok; <<"error">> -> ok;
<<"result">> -> ok; <<"result">> -> ok;
_ -> _ ->
@ -593,7 +593,7 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
_ -> _ ->
case mnesia:dirty_read(muc_online_room, {Room, Host}) of case mnesia:dirty_read(muc_online_room, {Room, Host}) of
[] -> [] ->
Type = xml:get_attr_s(<<"type">>, Attrs), Type = fxml:get_attr_s(<<"type">>, Attrs),
case {Name, Type} of case {Name, Type} of
{<<"presence">>, <<"">>} -> {<<"presence">>, <<"">>} ->
case check_user_can_create_room(ServerHost, case check_user_can_create_room(ServerHost,
@ -606,14 +606,14 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
mod_muc_room:route(Pid, From, Nick, Packet), mod_muc_room:route(Pid, From, Nick, Packet),
ok; ok;
false -> false ->
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs), Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
ErrText = <<"Room creation is denied by service policy">>, ErrText = <<"Room creation is denied by service policy">>,
Err = jlib:make_error_reply( Err = jlib:make_error_reply(
Packet, ?ERRT_FORBIDDEN(Lang, ErrText)), Packet, ?ERRT_FORBIDDEN(Lang, ErrText)),
ejabberd_router:route(To, From, Err) ejabberd_router:route(To, From, Err)
end; end;
_ -> _ ->
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs), Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
ErrText = <<"Conference room does not exist">>, ErrText = <<"Conference room does not exist">>,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_ITEM_NOT_FOUND(Lang, ErrText)), ?ERRT_ITEM_NOT_FOUND(Lang, ErrText)),
@ -1056,12 +1056,12 @@ iq_set_register_info(ServerHost, Host, From, Nick,
process_iq_register_set(ServerHost, Host, From, SubEl, process_iq_register_set(ServerHost, Host, From, SubEl,
Lang) -> Lang) ->
#xmlel{children = Els} = SubEl, #xmlel{children = Els} = SubEl,
case xml:get_subtag(SubEl, <<"remove">>) of case fxml:get_subtag(SubEl, <<"remove">>) of
false -> false ->
case xml:remove_cdata(Els) of case fxml:remove_cdata(Els) of
[#xmlel{name = <<"x">>} = XEl] -> [#xmlel{name = <<"x">>} = XEl] ->
case {xml:get_tag_attr_s(<<"xmlns">>, XEl), case {fxml:get_tag_attr_s(<<"xmlns">>, XEl),
xml:get_tag_attr_s(<<"type">>, XEl)} fxml:get_tag_attr_s(<<"type">>, XEl)}
of of
{?NS_XDATA, <<"cancel">>} -> {result, []}; {?NS_XDATA, <<"cancel">>} -> {result, []};
{?NS_XDATA, <<"submit">>} -> {?NS_XDATA, <<"submit">>} ->

View File

@ -193,15 +193,15 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}.
add_to_log2(text, {Nick, Packet}, Room, Opts, State) -> add_to_log2(text, {Nick, Packet}, Room, Opts, State) ->
case has_no_permanent_store_hint(Packet) of case has_no_permanent_store_hint(Packet) of
false -> false ->
case {xml:get_subtag(Packet, <<"subject">>), case {fxml:get_subtag(Packet, <<"subject">>),
xml:get_subtag(Packet, <<"body">>)} fxml:get_subtag(Packet, <<"body">>)}
of of
{false, false} -> ok; {false, false} -> ok;
{false, SubEl} -> {false, SubEl} ->
Message = {body, xml:get_tag_cdata(SubEl)}, Message = {body, fxml:get_tag_cdata(SubEl)},
add_message_to_log(Nick, Message, Room, Opts, State); add_message_to_log(Nick, Message, Room, Opts, State);
{SubEl, _} -> {SubEl, _} ->
Message = {subject, xml:get_tag_cdata(SubEl)}, Message = {subject, fxml:get_tag_cdata(SubEl)},
add_message_to_log(Nick, Message, Room, Opts, State) add_message_to_log(Nick, Message, Room, Opts, State)
end; end;
true -> ok true -> ok
@ -1201,13 +1201,13 @@ fjoin(FileList) ->
list_to_binary(filename:join([binary_to_list(File) || File <- FileList])). list_to_binary(filename:join([binary_to_list(File) || File <- FileList])).
has_no_permanent_store_hint(Packet) -> has_no_permanent_store_hint(Packet) ->
xml:get_subtag_with_xmlns(Packet, <<"no-store">>, ?NS_HINTS) fxml:get_subtag_with_xmlns(Packet, <<"no-store">>, ?NS_HINTS)
=/= false orelse =/= false orelse
xml:get_subtag_with_xmlns(Packet, <<"no-storage">>, ?NS_HINTS) fxml:get_subtag_with_xmlns(Packet, <<"no-storage">>, ?NS_HINTS)
=/= false orelse =/= false orelse
xml:get_subtag_with_xmlns(Packet, <<"no-permanent-store">>, ?NS_HINTS) fxml:get_subtag_with_xmlns(Packet, <<"no-permanent-store">>, ?NS_HINTS)
=/= false orelse =/= false orelse
xml:get_subtag_with_xmlns(Packet, <<"no-permanent-storage">>, ?NS_HINTS) fxml:get_subtag_with_xmlns(Packet, <<"no-permanent-storage">>, ?NS_HINTS)
=/= false. =/= false.
mod_opt_type(access_log) -> mod_opt_type(access_log) ->

View File

@ -143,12 +143,12 @@ normal_state({route, From, <<"">>,
children = Els} = children = Els} =
Packet}, Packet},
StateData) -> StateData) ->
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs), Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
case is_user_online(From, StateData) orelse case is_user_online(From, StateData) orelse
is_user_allowed_message_nonparticipant(From, StateData) is_user_allowed_message_nonparticipant(From, StateData)
of of
true -> true ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"groupchat">> -> <<"groupchat">> ->
Activity = get_user_activity(From, StateData), Activity = get_user_activity(From, StateData),
Now = p1_time_compat:system_time(micro_seconds), Now = p1_time_compat:system_time(micro_seconds),
@ -394,7 +394,7 @@ normal_state({route, From, <<"">>,
{next_state, normal_state, StateData} {next_state, normal_state, StateData}
end; end;
_ -> _ ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"error">> -> ok; <<"error">> -> ok;
_ -> _ ->
handle_roommessage_from_nonparticipant(Packet, Lang, handle_roommessage_from_nonparticipant(Packet, Lang,
@ -432,7 +432,7 @@ normal_state({route, From, <<"">>,
?NS_MUC_OWNER -> ?NS_MUC_OWNER ->
process_iq_owner(From, Type, Lang, SubEl, StateData); process_iq_owner(From, Type, Lang, SubEl, StateData);
?NS_DISCO_INFO -> ?NS_DISCO_INFO ->
case xml:get_attr(<<"node">>, Attrs) of case fxml:get_attr(<<"node">>, Attrs) of
false -> process_iq_disco_info(From, Type, Lang, StateData); false -> process_iq_disco_info(From, Type, Lang, StateData);
{value, _} -> {error, ?ERR_SERVICE_UNAVAILABLE} {value, _} -> {error, ?ERR_SERVICE_UNAVAILABLE}
end; end;
@ -509,8 +509,8 @@ normal_state({route, From, Nick,
normal_state({route, From, ToNick, normal_state({route, From, ToNick,
#xmlel{name = <<"message">>, attrs = Attrs} = Packet}, #xmlel{name = <<"message">>, attrs = Attrs} = Packet},
StateData) -> StateData) ->
Type = xml:get_attr_s(<<"type">>, Attrs), Type = fxml:get_attr_s(<<"type">>, Attrs),
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs), Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
case decide_fate_message(Type, Packet, From, StateData) case decide_fate_message(Type, Packet, From, StateData)
of of
{expulse_sender, Reason} -> {expulse_sender, Reason} ->
@ -568,7 +568,7 @@ normal_state({route, From, ToNick,
FromNick), FromNick),
X = #xmlel{name = <<"x">>, X = #xmlel{name = <<"x">>,
attrs = [{<<"xmlns">>, ?NS_MUC_USER}]}, attrs = [{<<"xmlns">>, ?NS_MUC_USER}]},
PrivMsg = xml:append_subtags(Packet, [X]), PrivMsg = fxml:append_subtags(Packet, [X]),
[ejabberd_router:route(FromNickJID, ToJID, PrivMsg) [ejabberd_router:route(FromNickJID, ToJID, PrivMsg)
|| ToJID <- ToJIDs]; || ToJID <- ToJIDs];
true -> true ->
@ -607,8 +607,8 @@ normal_state({route, From, ToNick,
normal_state({route, From, ToNick, normal_state({route, From, ToNick,
#xmlel{name = <<"iq">>, attrs = Attrs} = Packet}, #xmlel{name = <<"iq">>, attrs = Attrs} = Packet},
StateData) -> StateData) ->
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs), Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
StanzaId = xml:get_attr_s(<<"id">>, Attrs), StanzaId = fxml:get_attr_s(<<"id">>, Attrs),
case {(StateData#state.config)#config.allow_query_users, case {(StateData#state.config)#config.allow_query_users,
is_user_online_iq(StanzaId, From, StateData)} is_user_online_iq(StanzaId, From, StateData)}
of of
@ -884,7 +884,7 @@ route(Pid, From, ToNick, Packet) ->
process_groupchat_message(From, process_groupchat_message(From,
#xmlel{name = <<"message">>, attrs = Attrs} = Packet, #xmlel{name = <<"message">>, attrs = Attrs} = Packet,
StateData) -> StateData) ->
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs), Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
case is_user_online(From, StateData) orelse case is_user_online(From, StateData) orelse
is_user_allowed_message_nonparticipant(From, StateData) is_user_allowed_message_nonparticipant(From, StateData)
of of
@ -936,7 +936,7 @@ process_groupchat_message(From,
drop -> drop ->
{next_state, normal_state, StateData}; {next_state, normal_state, StateData};
NewPacket1 -> NewPacket1 ->
NewPacket = xml:remove_subtags(NewPacket1, <<"nick">>, {<<"xmlns">>, ?NS_NICK}), NewPacket = fxml:remove_subtags(NewPacket1, <<"nick">>, {<<"xmlns">>, ?NS_NICK}),
send_multiple(jid:replace_resource(StateData#state.jid, send_multiple(jid:replace_resource(StateData#state.jid,
FromNick), FromNick),
StateData#state.server_host, StateData#state.server_host,
@ -1016,7 +1016,7 @@ get_participant_data(From, StateData) ->
process_presence(From, Nick, process_presence(From, Nick,
#xmlel{name = <<"presence">>, attrs = Attrs0} = Packet0, #xmlel{name = <<"presence">>, attrs = Attrs0} = Packet0,
StateData) -> StateData) ->
Type0 = xml:get_attr_s(<<"type">>, Attrs0), Type0 = fxml:get_attr_s(<<"type">>, Attrs0),
IsOnline = is_user_online(From, StateData), IsOnline = is_user_online(From, StateData),
if Type0 == <<"">>; if Type0 == <<"">>;
IsOnline and ((Type0 == <<"unavailable">>) or (Type0 == <<"error">>)) -> IsOnline and ((Type0 == <<"unavailable">>) or (Type0 == <<"error">>)) ->
@ -1029,8 +1029,8 @@ process_presence(From, Nick,
drop -> drop ->
{next_state, normal_state, StateData}; {next_state, normal_state, StateData};
#xmlel{attrs = Attrs} = Packet -> #xmlel{attrs = Attrs} = Packet ->
Type = xml:get_attr_s(<<"type">>, Attrs), Type = fxml:get_attr_s(<<"type">>, Attrs),
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs), Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
StateData1 = case Type of StateData1 = case Type of
<<"unavailable">> -> <<"unavailable">> ->
NewPacket = case NewPacket = case
@ -1047,12 +1047,12 @@ process_presence(From, Nick,
{ok, [_, _ | _]} -> ok; {ok, [_, _ | _]} -> ok;
_ -> send_new_presence(From, NewState, StateData) _ -> send_new_presence(From, NewState, StateData)
end, end,
Reason = case xml:get_subtag(NewPacket, Reason = case fxml:get_subtag(NewPacket,
<<"status">>) <<"status">>)
of of
false -> <<"">>; false -> <<"">>;
Status_el -> Status_el ->
xml:get_tag_cdata(Status_el) fxml:get_tag_cdata(Status_el)
end, end,
remove_online_user(From, NewState, Reason); remove_online_user(From, NewState, Reason);
<<"error">> -> <<"error">> ->
@ -1087,7 +1087,7 @@ process_presence(From, Nick,
From, Err), From, Err),
StateData; StateData;
{true, _, _} -> {true, _, _} ->
Lang = xml:get_attr_s(<<"xml:lang">>, Lang = fxml:get_attr_s(<<"xml:lang">>,
Attrs), Attrs),
ErrText = ErrText =
<<"That nickname is already in use by another " <<"That nickname is already in use by another "
@ -1304,7 +1304,7 @@ get_error_condition(Packet) ->
end. end.
get_error_condition2(Packet) -> get_error_condition2(Packet) ->
#xmlel{children = EEls} = xml:get_subtag(Packet, #xmlel{children = EEls} = fxml:get_subtag(Packet,
<<"error">>), <<"error">>),
[Condition] = [Name [Condition] = [Name
|| #xmlel{name = Name, || #xmlel{name = Name,
@ -1655,7 +1655,7 @@ filter_presence(#xmlel{name = <<"presence">>,
case El of case El of
{xmlcdata, _} -> false; {xmlcdata, _} -> false;
#xmlel{attrs = Attrs1} -> #xmlel{attrs = Attrs1} ->
XMLNS = xml:get_attr_s(<<"xmlns">>, XMLNS = fxml:get_attr_s(<<"xmlns">>,
Attrs1), Attrs1),
NS_MUC = ?NS_MUC, NS_MUC = ?NS_MUC,
Size = byte_size(NS_MUC), Size = byte_size(NS_MUC),
@ -1743,11 +1743,11 @@ higher_presence(Pres1, Pres2) ->
Pri1 > Pri2. Pri1 > Pri2.
get_priority_from_presence(PresencePacket) -> get_priority_from_presence(PresencePacket) ->
case xml:get_subtag(PresencePacket, <<"priority">>) of case fxml:get_subtag(PresencePacket, <<"priority">>) of
false -> 0; false -> 0;
SubEl -> SubEl ->
case catch case catch
jlib:binary_to_integer(xml:get_tag_cdata(SubEl)) jlib:binary_to_integer(fxml:get_tag_cdata(SubEl))
of of
P when is_integer(P) -> P; P when is_integer(P) -> P;
_ -> 0 _ -> 0
@ -1781,7 +1781,7 @@ nick_collision(User, Nick, StateData) ->
add_new_user(From, Nick, add_new_user(From, Nick,
#xmlel{attrs = Attrs, children = Els} = Packet, #xmlel{attrs = Attrs, children = Els} = Packet,
StateData) -> StateData) ->
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs), Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
MaxUsers = get_max_users(StateData), MaxUsers = get_max_users(StateData),
MaxAdminUsers = MaxUsers + MaxAdminUsers = MaxUsers +
get_max_users_admin_threshold(StateData), get_max_users_admin_threshold(StateData),
@ -1879,7 +1879,7 @@ add_new_user(From, Nick,
From, Err), From, Err),
StateData; StateData;
captcha_required -> captcha_required ->
SID = xml:get_attr_s(<<"id">>, Attrs), SID = fxml:get_attr_s(<<"id">>, Attrs),
RoomJID = StateData#state.jid, RoomJID = StateData#state.jid,
To = jid:replace_resource(RoomJID, Nick), To = jid:replace_resource(RoomJID, Nick),
Limiter = {From#jid.luser, From#jid.lserver}, Limiter = {From#jid.luser, From#jid.lserver},
@ -1979,11 +1979,11 @@ check_captcha(Affiliation, From, StateData) ->
extract_password([]) -> false; extract_password([]) -> false;
extract_password([#xmlel{attrs = Attrs} = El | Els]) -> extract_password([#xmlel{attrs = Attrs} = El | Els]) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_MUC -> ?NS_MUC ->
case xml:get_subtag(El, <<"password">>) of case fxml:get_subtag(El, <<"password">>) of
false -> false; false -> false;
SubEl -> xml:get_tag_cdata(SubEl) SubEl -> fxml:get_tag_cdata(SubEl)
end; end;
_ -> extract_password(Els) _ -> extract_password(Els)
end; end;
@ -2057,9 +2057,9 @@ calc_shift(MaxSize, Size, Shift, [S | TSizes]) ->
extract_history([], _Type) -> false; extract_history([], _Type) -> false;
extract_history([#xmlel{attrs = Attrs} = El | Els], extract_history([#xmlel{attrs = Attrs} = El | Els],
Type) -> Type) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_MUC -> ?NS_MUC ->
AttrVal = xml:get_path_s(El, AttrVal = fxml:get_path_s(El,
[{elem, <<"history">>}, {attr, Type}]), [{elem, <<"history">>}, {attr, Type}]),
case Type of case Type of
<<"since">> -> <<"since">> ->
@ -2232,7 +2232,7 @@ send_new_presence1(NJID, Reason, StateData, OldStateData) ->
end; end;
false -> Status3 false -> Status3
end, end,
Packet = xml:append_subtags(Presence, Packet = fxml:append_subtags(Presence,
[#xmlel{name = <<"x">>, [#xmlel{name = <<"x">>,
attrs = attrs =
[{<<"xmlns">>, [{<<"xmlns">>,
@ -2295,7 +2295,7 @@ send_existing_presences1(ToJID, StateData) ->
{<<"role">>, {<<"role">>,
role_to_list(FromRole)}] role_to_list(FromRole)}]
end, end,
Packet = xml:append_subtags(Presence, Packet = fxml:append_subtags(Presence,
[#xmlel{name = [#xmlel{name =
<<"x">>, <<"x">>,
attrs = attrs =
@ -2426,7 +2426,7 @@ send_nick_changing(JID, OldNick, StateData,
<<"303">>}], <<"303">>}],
children = children =
[]}|Status110]}]}, []}|Status110]}]},
Packet2 = xml:append_subtags(Presence, Packet2 = fxml:append_subtags(Presence,
[#xmlel{name = <<"x">>, [#xmlel{name = <<"x">>,
attrs = attrs =
[{<<"xmlns">>, [{<<"xmlns">>,
@ -2480,7 +2480,7 @@ lqueue_to_list(#lqueue{queue = Q1}) ->
add_message_to_history(FromNick, FromJID, Packet, StateData) -> add_message_to_history(FromNick, FromJID, Packet, StateData) ->
HaveSubject = case xml:get_subtag(Packet, <<"subject">>) HaveSubject = case fxml:get_subtag(Packet, <<"subject">>)
of of
false -> false; false -> false;
_ -> true _ -> true
@ -2497,7 +2497,7 @@ add_message_to_history(FromNick, FromJID, Packet, StateData) ->
Addresses = #xmlel{name = <<"addresses">>, Addresses = #xmlel{name = <<"addresses">>,
attrs = [{<<"xmlns">>, ?NS_ADDRESS}], attrs = [{<<"xmlns">>, ?NS_ADDRESS}],
children = [Address]}, children = [Address]},
xml:append_subtags(Packet, [Addresses]) fxml:append_subtags(Packet, [Addresses])
end, end,
TSPacket = jlib:add_delay_info(AddrPacket, StateData#state.jid, TimeStamp), TSPacket = jlib:add_delay_info(AddrPacket, StateData#state.jid, TimeStamp),
SPacket = SPacket =
@ -2536,9 +2536,9 @@ send_subject(JID, #state{subject_author = Nick} = StateData) ->
Packet). Packet).
check_subject(Packet) -> check_subject(Packet) ->
case xml:get_subtag(Packet, <<"subject">>) of case fxml:get_subtag(Packet, <<"subject">>) of
false -> false; false -> false;
SubjEl -> xml:get_tag_cdata(SubjEl) SubjEl -> fxml:get_tag_cdata(SubjEl)
end. end.
can_change_subject(Role, StateData) -> can_change_subject(Role, StateData) ->
@ -2555,14 +2555,14 @@ process_iq_admin(From, set, Lang, SubEl, StateData) ->
#xmlel{children = Items} = SubEl, #xmlel{children = Items} = SubEl,
process_admin_items_set(From, Items, Lang, StateData); process_admin_items_set(From, Items, Lang, StateData);
process_iq_admin(From, get, Lang, SubEl, StateData) -> process_iq_admin(From, get, Lang, SubEl, StateData) ->
case xml:get_subtag(SubEl, <<"item">>) of case fxml:get_subtag(SubEl, <<"item">>) of
false -> {error, ?ERR_BAD_REQUEST}; false -> {error, ?ERR_BAD_REQUEST};
Item -> Item ->
FAffiliation = get_affiliation(From, StateData), FAffiliation = get_affiliation(From, StateData),
FRole = get_role(From, StateData), FRole = get_role(From, StateData),
case xml:get_tag_attr(<<"role">>, Item) of case fxml:get_tag_attr(<<"role">>, Item) of
false -> false ->
case xml:get_tag_attr(<<"affiliation">>, Item) of case fxml:get_tag_attr(<<"affiliation">>, Item) of
false -> {error, ?ERR_BAD_REQUEST}; false -> {error, ?ERR_BAD_REQUEST};
{value, StrAffiliation} -> {value, StrAffiliation} ->
case catch list_to_affiliation(StrAffiliation) of case catch list_to_affiliation(StrAffiliation) of
@ -2754,7 +2754,7 @@ find_changed_items(UJID, UAffiliation, URole,
[#xmlel{name = <<"item">>, attrs = Attrs} = Item [#xmlel{name = <<"item">>, attrs = Attrs} = Item
| Items], | Items],
Lang, StateData, Res) -> Lang, StateData, Res) ->
TJID = case xml:get_attr(<<"jid">>, Attrs) of TJID = case fxml:get_attr(<<"jid">>, Attrs) of
{value, S} -> {value, S} ->
case jid:from_string(S) of case jid:from_string(S) of
error -> error ->
@ -2767,7 +2767,7 @@ find_changed_items(UJID, UAffiliation, URole,
J -> {value, [J]} J -> {value, [J]}
end; end;
_ -> _ ->
case xml:get_attr(<<"nick">>, Attrs) of case fxml:get_attr(<<"nick">>, Attrs) of
{value, N} -> {value, N} ->
case find_jids_by_nick(N, StateData) of case find_jids_by_nick(N, StateData) of
false -> false ->
@ -2787,9 +2787,9 @@ find_changed_items(UJID, UAffiliation, URole,
{value, [JID | _] = JIDs} -> {value, [JID | _] = JIDs} ->
TAffiliation = get_affiliation(JID, StateData), TAffiliation = get_affiliation(JID, StateData),
TRole = get_role(JID, StateData), TRole = get_role(JID, StateData),
case xml:get_attr(<<"role">>, Attrs) of case fxml:get_attr(<<"role">>, Attrs) of
false -> false ->
case xml:get_attr(<<"affiliation">>, Attrs) of case fxml:get_attr(<<"affiliation">>, Attrs) of
false -> {error, ?ERR_BAD_REQUEST}; false -> {error, ?ERR_BAD_REQUEST};
{value, StrAffiliation} -> {value, StrAffiliation} ->
case catch list_to_affiliation(StrAffiliation) of case catch list_to_affiliation(StrAffiliation) of
@ -2830,7 +2830,7 @@ find_changed_items(UJID, UAffiliation, URole,
Items, Lang, StateData, Items, Lang, StateData,
Res); Res);
true -> true ->
Reason = xml:get_path_s(Item, Reason = fxml:get_path_s(Item,
[{elem, <<"reason">>}, [{elem, <<"reason">>},
cdata]), cdata]),
MoreRes = [{jid:remove_resource(Jidx), MoreRes = [{jid:remove_resource(Jidx),
@ -2877,7 +2877,7 @@ find_changed_items(UJID, UAffiliation, URole,
find_changed_items(UJID, UAffiliation, URole, Items, find_changed_items(UJID, UAffiliation, URole, Items,
Lang, StateData, Res); Lang, StateData, Res);
true -> true ->
Reason = xml:get_path_s(Item, Reason = fxml:get_path_s(Item,
[{elem, <<"reason">>}, [{elem, <<"reason">>},
cdata]), cdata]),
MoreRes = [{Jidx, role, SRole, Reason} MoreRes = [{Jidx, role, SRole, Reason}
@ -3129,10 +3129,10 @@ process_iq_owner(From, set, Lang, SubEl, StateData) ->
case FAffiliation of case FAffiliation of
owner -> owner ->
#xmlel{children = Els} = SubEl, #xmlel{children = Els} = SubEl,
case xml:remove_cdata(Els) of case fxml:remove_cdata(Els) of
[#xmlel{name = <<"x">>} = XEl] -> [#xmlel{name = <<"x">>} = XEl] ->
case {xml:get_tag_attr_s(<<"xmlns">>, XEl), case {fxml:get_tag_attr_s(<<"xmlns">>, XEl),
xml:get_tag_attr_s(<<"type">>, XEl)} fxml:get_tag_attr_s(<<"type">>, XEl)}
of of
{?NS_XDATA, <<"cancel">>} -> {result, [], StateData}; {?NS_XDATA, <<"cancel">>} -> {result, [], StateData};
{?NS_XDATA, <<"submit">>} -> {?NS_XDATA, <<"submit">>} ->
@ -3166,10 +3166,10 @@ process_iq_owner(From, get, Lang, SubEl, StateData) ->
case FAffiliation of case FAffiliation of
owner -> owner ->
#xmlel{children = Els} = SubEl, #xmlel{children = Els} = SubEl,
case xml:remove_cdata(Els) of case fxml:remove_cdata(Els) of
[] -> get_config(Lang, StateData, From); [] -> get_config(Lang, StateData, From);
[Item] -> [Item] ->
case xml:get_tag_attr(<<"affiliation">>, Item) of case fxml:get_tag_attr(<<"affiliation">>, Item) of
false -> {error, ?ERR_BAD_REQUEST}; false -> {error, ?ERR_BAD_REQUEST};
{value, StrAffiliation} -> {value, StrAffiliation} ->
case catch list_to_affiliation(StrAffiliation) of case catch list_to_affiliation(StrAffiliation) of
@ -4225,7 +4225,7 @@ process_iq_captcha(_From, set, _Lang, SubEl,
process_iq_vcard(_From, get, _Lang, _SubEl, StateData) -> process_iq_vcard(_From, get, _Lang, _SubEl, StateData) ->
#state{config = #config{vcard = VCardRaw}} = StateData, #state{config = #config{vcard = VCardRaw}} = StateData,
case xml_stream:parse_element(VCardRaw) of case fxml_stream:parse_element(VCardRaw) of
#xmlel{children = VCardEls} -> #xmlel{children = VCardEls} ->
{result, VCardEls, StateData}; {result, VCardEls, StateData};
{error, _} -> {error, _} ->
@ -4234,7 +4234,7 @@ process_iq_vcard(_From, get, _Lang, _SubEl, StateData) ->
process_iq_vcard(From, set, Lang, SubEl, StateData) -> process_iq_vcard(From, set, Lang, SubEl, StateData) ->
case get_affiliation(From, StateData) of case get_affiliation(From, StateData) of
owner -> owner ->
VCardRaw = xml:element_to_binary(SubEl), VCardRaw = fxml:element_to_binary(SubEl),
Config = StateData#state.config, Config = StateData#state.config,
NewConfig = Config#config{vcard = VCardRaw}, NewConfig = Config#config{vcard = VCardRaw},
change_config(NewConfig, StateData); change_config(NewConfig, StateData);
@ -4293,7 +4293,7 @@ is_voice_request(Els) ->
lists:foldl(fun (#xmlel{name = <<"x">>, attrs = Attrs} = lists:foldl(fun (#xmlel{name = <<"x">>, attrs = Attrs} =
El, El,
false) -> false) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_XDATA -> ?NS_XDATA ->
case jlib:parse_xdata_submit(El) of case jlib:parse_xdata_submit(El) of
[_ | _] = Fields -> [_ | _] = Fields ->
@ -4376,7 +4376,7 @@ is_voice_approvement(Els) ->
lists:foldl(fun (#xmlel{name = <<"x">>, attrs = Attrs} = lists:foldl(fun (#xmlel{name = <<"x">>, attrs = Attrs} =
El, El,
false) -> false) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_XDATA -> ?NS_XDATA ->
case jlib:parse_xdata_submit(El) of case jlib:parse_xdata_submit(El) of
[_ | _] = Fs -> [_ | _] = Fs ->
@ -4430,9 +4430,9 @@ is_invitation(Els) ->
lists:foldl(fun (#xmlel{name = <<"x">>, attrs = Attrs} = lists:foldl(fun (#xmlel{name = <<"x">>, attrs = Attrs} =
El, El,
false) -> false) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_MUC_USER -> ?NS_MUC_USER ->
case xml:get_subtag(El, <<"invite">>) of case fxml:get_subtag(El, <<"invite">>) of
false -> false; false -> false;
_ -> true _ -> true
end; end;
@ -4448,20 +4448,20 @@ check_invitation(From, Els, Lang, StateData) ->
(StateData#state.config)#config.allow_user_invites (StateData#state.config)#config.allow_user_invites
orelse orelse
FAffiliation == admin orelse FAffiliation == owner, FAffiliation == admin orelse FAffiliation == owner,
InviteEl = case xml:remove_cdata(Els) of InviteEl = case fxml:remove_cdata(Els) of
[#xmlel{name = <<"x">>, children = Els1} = XEl] -> [#xmlel{name = <<"x">>, children = Els1} = XEl] ->
case xml:get_tag_attr_s(<<"xmlns">>, XEl) of case fxml:get_tag_attr_s(<<"xmlns">>, XEl) of
?NS_MUC_USER -> ok; ?NS_MUC_USER -> ok;
_ -> throw({error, ?ERR_BAD_REQUEST}) _ -> throw({error, ?ERR_BAD_REQUEST})
end, end,
case xml:remove_cdata(Els1) of case fxml:remove_cdata(Els1) of
[#xmlel{name = <<"invite">>} = InviteEl1] -> InviteEl1; [#xmlel{name = <<"invite">>} = InviteEl1] -> InviteEl1;
_ -> throw({error, ?ERR_BAD_REQUEST}) _ -> throw({error, ?ERR_BAD_REQUEST})
end; end;
_ -> throw({error, ?ERR_BAD_REQUEST}) _ -> throw({error, ?ERR_BAD_REQUEST})
end, end,
JID = case JID = case
jid:from_string(xml:get_tag_attr_s(<<"to">>, jid:from_string(fxml:get_tag_attr_s(<<"to">>,
InviteEl)) InviteEl))
of of
error -> throw({error, ?ERR_JID_MALFORMED}); error -> throw({error, ?ERR_JID_MALFORMED});
@ -4470,9 +4470,9 @@ check_invitation(From, Els, Lang, StateData) ->
case CanInvite of case CanInvite of
false -> throw({error, ?ERR_NOT_ALLOWED}); false -> throw({error, ?ERR_NOT_ALLOWED});
true -> true ->
Reason = xml:get_path_s(InviteEl, Reason = fxml:get_path_s(InviteEl,
[{elem, <<"reason">>}, cdata]), [{elem, <<"reason">>}, cdata]),
ContinueEl = case xml:get_path_s(InviteEl, ContinueEl = case fxml:get_path_s(InviteEl,
[{elem, <<"continue">>}]) [{elem, <<"continue">>}])
of of
<<>> -> []; <<>> -> [];
@ -4562,10 +4562,10 @@ handle_roommessage_from_nonparticipant(Packet, Lang,
%% because it crashes when the packet is not a decline message. %% because it crashes when the packet is not a decline message.
check_decline_invitation(Packet) -> check_decline_invitation(Packet) ->
#xmlel{name = <<"message">>} = Packet, #xmlel{name = <<"message">>} = Packet,
XEl = xml:get_subtag(Packet, <<"x">>), XEl = fxml:get_subtag(Packet, <<"x">>),
(?NS_MUC_USER) = xml:get_tag_attr_s(<<"xmlns">>, XEl), (?NS_MUC_USER) = fxml:get_tag_attr_s(<<"xmlns">>, XEl),
DEl = xml:get_subtag(XEl, <<"decline">>), DEl = fxml:get_subtag(XEl, <<"decline">>),
ToString = xml:get_tag_attr_s(<<"to">>, DEl), ToString = fxml:get_tag_attr_s(<<"to">>, DEl),
ToJID = jid:from_string(ToString), ToJID = jid:from_string(ToString),
{true, {Packet, XEl, DEl, ToJID}}. {true, {Packet, XEl, DEl, ToJID}}.
@ -4652,7 +4652,7 @@ tab_count_user(JID) ->
end. end.
element_size(El) -> element_size(El) ->
byte_size(xml:element_to_binary(El)). byte_size(fxml:element_to_binary(El)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Multicast %% Multicast

View File

@ -233,7 +233,7 @@ handle_iq(From, To, #xmlel{attrs = Attrs} = Packet, State) ->
ejabberd_router:route(To, From, Err); ejabberd_router:route(To, From, Err);
reply -> reply ->
LServiceS = jts(To), LServiceS = jts(To),
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"result">> -> <<"result">> ->
process_iqreply_result(From, LServiceS, Packet, State); process_iqreply_result(From, LServiceS, Packet, State);
<<"error">> -> <<"error">> ->
@ -436,17 +436,17 @@ check_access(LServerS, Access, From) ->
%%%------------------------- %%%-------------------------
strip_addresses_element(Packet) -> strip_addresses_element(Packet) ->
case xml:get_subtag(Packet, <<"addresses">>) of case fxml:get_subtag(Packet, <<"addresses">>) of
#xmlel{name = <<"addresses">>, attrs = AAttrs, #xmlel{name = <<"addresses">>, attrs = AAttrs,
children = Addresses} -> children = Addresses} ->
case xml:get_attr_s(<<"xmlns">>, AAttrs) of case fxml:get_attr_s(<<"xmlns">>, AAttrs) of
?NS_ADDRESS -> ?NS_ADDRESS ->
#xmlel{name = Name, attrs = Attrs, children = Els} = #xmlel{name = Name, attrs = Attrs, children = Els} =
Packet, Packet,
Els_stripped = lists:keydelete(<<"addresses">>, 2, Els), Els_stripped = lists:keydelete(<<"addresses">>, 2, Els),
Packet_stripped = #xmlel{name = Name, attrs = Attrs, Packet_stripped = #xmlel{name = Name, attrs = Attrs,
children = Els_stripped}, children = Els_stripped},
{ok, Packet_stripped, AAttrs, xml:remove_cdata(Addresses)}; {ok, Packet_stripped, AAttrs, fxml:remove_cdata(Addresses)};
_ -> throw(ewxmlns) _ -> throw(ewxmlns)
end; end;
_ -> throw(eadsele) _ -> throw(eadsele)
@ -460,10 +460,10 @@ split_addresses_todeliver(Addresses) ->
lists:partition(fun (XML) -> lists:partition(fun (XML) ->
case XML of case XML of
#xmlel{name = <<"address">>, attrs = Attrs} -> #xmlel{name = <<"address">>, attrs = Attrs} ->
case xml:get_attr_s(<<"delivered">>, Attrs) of case fxml:get_attr_s(<<"delivered">>, Attrs) of
<<"true">> -> false; <<"true">> -> false;
_ -> _ ->
Type = xml:get_attr_s(<<"type">>, Type = fxml:get_attr_s(<<"type">>,
Attrs), Attrs),
case Type of case Type of
<<"to">> -> true; <<"to">> -> true;
@ -499,10 +499,10 @@ check_limit_dests(SLimits, FromJID, Packet,
convert_dest_record(XMLs) -> convert_dest_record(XMLs) ->
lists:map(fun (XML) -> lists:map(fun (XML) ->
case xml:get_tag_attr_s(<<"jid">>, XML) of case fxml:get_tag_attr_s(<<"jid">>, XML) of
<<"">> -> #dest{jid_string = none, full_xml = XML}; <<"">> -> #dest{jid_string = none, full_xml = XML};
JIDS -> JIDS ->
Type = xml:get_tag_attr_s(<<"type">>, XML), Type = fxml:get_tag_attr_s(<<"type">>, XML),
JIDJ = stj(JIDS), JIDJ = stj(JIDS),
#dest{jid_string = JIDS, jid_jid = JIDJ, #dest{jid_string = JIDS, jid_jid = JIDJ,
type = Type, full_xml = XML} type = Type, full_xml = XML}
@ -525,7 +525,7 @@ split_dests_jid(Dests) ->
Dests). Dests).
report_not_jid(From, Packet, Dests) -> report_not_jid(From, Packet, Dests) ->
Dests2 = [xml:element_to_binary(Dest#dest.full_xml) Dests2 = [fxml:element_to_binary(Dest#dest.full_xml)
|| Dest <- Dests], || Dest <- Dests],
[route_error(From, From, Packet, jid_malformed, [route_error(From, From, Packet, jid_malformed,
<<"This service can not process the address: ", <<"This service can not process the address: ",
@ -734,8 +734,8 @@ process_iqreply_error(From, LServiceS, _Packet) ->
process_iqreply_result(From, LServiceS, Packet, State) -> process_iqreply_result(From, LServiceS, Packet, State) ->
#xmlel{name = <<"query">>, attrs = Attrs2, #xmlel{name = <<"query">>, attrs = Attrs2,
children = Els2} = children = Els2} =
xml:get_subtag(Packet, <<"query">>), fxml:get_subtag(Packet, <<"query">>),
case xml:get_attr_s(<<"xmlns">>, Attrs2) of case fxml:get_attr_s(<<"xmlns">>, Attrs2) of
?NS_DISCO_INFO -> ?NS_DISCO_INFO ->
process_discoinfo_result(From, LServiceS, Els2, State); process_discoinfo_result(From, LServiceS, Els2, State);
?NS_DISCO_ITEMS -> ?NS_DISCO_ITEMS ->
@ -763,7 +763,7 @@ process_discoinfo_result2(From, FromS, LServiceS, Els,
fun(XML) -> fun(XML) ->
case XML of case XML of
#xmlel{name = <<"feature">>, attrs = Attrs} -> #xmlel{name = <<"feature">>, attrs = Attrs} ->
(?NS_ADDRESS) == xml:get_attr_s(<<"var">>, Attrs); (?NS_ADDRESS) == fxml:get_attr_s(<<"var">>, Attrs);
_ -> false _ -> false
end end
end, end,
@ -807,10 +807,10 @@ get_limits_els(Els) ->
#xmlel{name = <<"x">>, attrs = Attrs, #xmlel{name = <<"x">>, attrs = Attrs,
children = SubEls} -> children = SubEls} ->
case ((?NS_XDATA) == case ((?NS_XDATA) ==
xml:get_attr_s(<<"xmlns">>, Attrs)) fxml:get_attr_s(<<"xmlns">>, Attrs))
and and
(<<"result">> == (<<"result">> ==
xml:get_attr_s(<<"type">>, Attrs)) fxml:get_attr_s(<<"type">>, Attrs))
of of
true -> get_limits_fields(SubEls) ++ R; true -> get_limits_fields(SubEls) ++ R;
false -> R false -> R
@ -826,11 +826,11 @@ get_limits_fields(Fields) ->
#xmlel{name = <<"field">>, #xmlel{name = <<"field">>,
attrs = Attrs} -> attrs = Attrs} ->
(<<"FORM_TYPE">> == (<<"FORM_TYPE">> ==
xml:get_attr_s(<<"var">>, fxml:get_attr_s(<<"var">>,
Attrs)) Attrs))
and and
(<<"hidden">> == (<<"hidden">> ==
xml:get_attr_s(<<"type">>, fxml:get_attr_s(<<"type">>,
Attrs)); Attrs));
_ -> false _ -> false
end end
@ -848,8 +848,8 @@ get_limits_values(Values) ->
children = SubEls} -> children = SubEls} ->
[#xmlel{name = <<"value">>, children = SubElsV}] = [#xmlel{name = <<"value">>, children = SubElsV}] =
SubEls, SubEls,
Number = xml:get_cdata(SubElsV), Number = fxml:get_cdata(SubElsV),
Name = xml:get_attr_s(<<"var">>, Attrs), Name = fxml:get_attr_s(<<"var">>, Attrs),
[{jlib:binary_to_atom(Name), [{jlib:binary_to_atom(Name),
jlib:binary_to_integer(Number)} jlib:binary_to_integer(Number)}
| R]; | R];
@ -870,7 +870,7 @@ process_discoitems_result(From, LServiceS, Els) ->
fun(XML, Res) -> fun(XML, Res) ->
case XML of case XML of
#xmlel{name = <<"item">>, attrs = Attrs} -> #xmlel{name = <<"item">>, attrs = Attrs} ->
SJID = xml:get_attr_s(<<"jid">>, Attrs), SJID = fxml:get_attr_s(<<"jid">>, Attrs),
case jid:from_string(SJID) of case jid:from_string(SJID) of
#jid{luser = <<"">>, #jid{luser = <<"">>,
lresource = <<"">>} -> lresource = <<"">>} ->
@ -1196,7 +1196,7 @@ to_binary(A) -> list_to_binary(hd(io_lib:format("~p", [A]))).
route_error(From, To, Packet, ErrType, ErrText) -> route_error(From, To, Packet, ErrType, ErrText) ->
#xmlel{attrs = Attrs} = Packet, #xmlel{attrs = Attrs} = Packet,
Lang = xml:get_attr_s(<<"xml:lang">>, Attrs), Lang = fxml:get_attr_s(<<"xml:lang">>, Attrs),
Reply = make_reply(ErrType, Lang, ErrText), Reply = make_reply(ErrType, Lang, ErrText),
Err = jlib:make_error_reply(Packet, Reply), Err = jlib:make_error_reply(Packet, Reply),
ejabberd_router:route(From, To, Err). ejabberd_router:route(From, To, Err).

View File

@ -227,7 +227,7 @@ store_offline_msg(Host, {User, _Server}, Msgs, Len, MaxOfflineMsgs, odbc) ->
M#offline_msg.timestamp, M#offline_msg.timestamp,
<<"Offline Storage">>), <<"Offline Storage">>),
XML = XML =
ejabberd_odbc:escape(xml:element_to_binary(NewPacket)), ejabberd_odbc:escape(fxml:element_to_binary(NewPacket)),
odbc_queries:add_spool_sql(Username, XML) odbc_queries:add_spool_sql(Username, XML)
end, end,
Msgs), Msgs),
@ -286,7 +286,7 @@ get_sm_features(Acc, _From, _To, _Node, _Lang) ->
Acc. Acc.
need_to_store(LServer, Packet) -> need_to_store(LServer, Packet) ->
Type = xml:get_tag_attr_s(<<"type">>, Packet), Type = fxml:get_tag_attr_s(<<"type">>, Packet),
if (Type /= <<"error">>) and (Type /= <<"groupchat">>) if (Type /= <<"error">>) and (Type /= <<"groupchat">>)
and (Type /= <<"headline">>) -> and (Type /= <<"headline">>) ->
case check_store_hint(Packet) of case check_store_hint(Packet) of
@ -302,7 +302,7 @@ need_to_store(LServer, Packet) ->
end, end,
unless_chat_state) of unless_chat_state) of
false -> false ->
xml:get_subtag(Packet, <<"body">>) /= false; fxml:get_subtag(Packet, <<"body">>) /= false;
unless_chat_state -> unless_chat_state ->
not jlib:is_standalone_chat_state(Packet); not jlib:is_standalone_chat_state(Packet);
true -> true ->
@ -346,12 +346,12 @@ check_store_hint(Packet) ->
end. end.
has_store_hint(Packet) -> has_store_hint(Packet) ->
xml:get_subtag_with_xmlns(Packet, <<"store">>, ?NS_HINTS) =/= false. fxml:get_subtag_with_xmlns(Packet, <<"store">>, ?NS_HINTS) =/= false.
has_no_store_hint(Packet) -> has_no_store_hint(Packet) ->
xml:get_subtag_with_xmlns(Packet, <<"no-store">>, ?NS_HINTS) =/= false fxml:get_subtag_with_xmlns(Packet, <<"no-store">>, ?NS_HINTS) =/= false
orelse orelse
xml:get_subtag_with_xmlns(Packet, <<"no-storage">>, ?NS_HINTS) =/= false. fxml:get_subtag_with_xmlns(Packet, <<"no-storage">>, ?NS_HINTS) =/= false.
%% Check if the packet has any content about XEP-0022 %% Check if the packet has any content about XEP-0022
check_event(From, To, Packet) -> check_event(From, To, Packet) ->
@ -360,12 +360,12 @@ check_event(From, To, Packet) ->
case find_x_event(Els) of case find_x_event(Els) of
false -> true; false -> true;
El -> El ->
case xml:get_subtag(El, <<"id">>) of case fxml:get_subtag(El, <<"id">>) of
false -> false ->
case xml:get_subtag(El, <<"offline">>) of case fxml:get_subtag(El, <<"offline">>) of
false -> true; false -> true;
_ -> _ ->
ID = case xml:get_tag_attr_s(<<"id">>, Packet) of ID = case fxml:get_tag_attr_s(<<"id">>, Packet) of
<<"">> -> <<"">> ->
#xmlel{name = <<"id">>, attrs = [], #xmlel{name = <<"id">>, attrs = [],
children = []}; children = []};
@ -402,7 +402,7 @@ find_x_event([]) -> false;
find_x_event([{xmlcdata, _} | Els]) -> find_x_event([{xmlcdata, _} | Els]) ->
find_x_event(Els); find_x_event(Els);
find_x_event([El | Els]) -> find_x_event([El | Els]) ->
case xml:get_tag_attr_s(<<"xmlns">>, El) of case fxml:get_tag_attr_s(<<"xmlns">>, El) of
?NS_EVENT -> El; ?NS_EVENT -> El;
_ -> find_x_event(Els) _ -> find_x_event(Els)
end. end.
@ -411,9 +411,9 @@ find_x_expire(_, []) -> never;
find_x_expire(TimeStamp, [{xmlcdata, _} | Els]) -> find_x_expire(TimeStamp, [{xmlcdata, _} | Els]) ->
find_x_expire(TimeStamp, Els); find_x_expire(TimeStamp, Els);
find_x_expire(TimeStamp, [El | Els]) -> find_x_expire(TimeStamp, [El | Els]) ->
case xml:get_tag_attr_s(<<"xmlns">>, El) of case fxml:get_tag_attr_s(<<"xmlns">>, El) of
?NS_EXPIRE -> ?NS_EXPIRE ->
Val = xml:get_tag_attr_s(<<"seconds">>, El), Val = fxml:get_tag_attr_s(<<"seconds">>, El),
case catch jlib:binary_to_integer(Val) of case catch jlib:binary_to_integer(Val) of
{'EXIT', _} -> never; {'EXIT', _} -> never;
Int when Int > 0 -> Int when Int > 0 ->
@ -487,7 +487,7 @@ pop_offline_messages(Ls, LUser, LServer, odbc) ->
{atomic, {selected, [<<"username">>, <<"xml">>], Rs}} -> {atomic, {selected, [<<"username">>, <<"xml">>], Rs}} ->
Ls ++ Ls ++
lists:flatmap(fun ([_, XML]) -> lists:flatmap(fun ([_, XML]) ->
case xml_stream:parse_element(XML) of case fxml_stream:parse_element(XML) of
{error, _Reason} -> {error, _Reason} ->
[]; [];
El -> El ->
@ -635,7 +635,7 @@ update_table() ->
iolist_to_binary(S)}, iolist_to_binary(S)},
from = jid_to_binary(From), from = jid_to_binary(From),
to = jid_to_binary(To), to = jid_to_binary(To),
packet = xml:to_xmlel(El)} packet = fxml:to_xmlel(El)}
end); end);
_ -> _ ->
?INFO_MSG("Recreating offline_msg table", []), ?INFO_MSG("Recreating offline_msg table", []),
@ -650,7 +650,7 @@ discard_warn_sender(Msgs) ->
packet = Packet}) -> packet = Packet}) ->
ErrText = <<"Your contact offline message queue is " ErrText = <<"Your contact offline message queue is "
"full. The message has been discarded.">>, "full. The message has been discarded.">>,
Lang = xml:get_tag_attr_s(<<"xml:lang">>, Packet), Lang = fxml:get_tag_attr_s(<<"xml:lang">>, Packet),
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_RESOURCE_CONSTRAINT(Lang, ?ERRT_RESOURCE_CONSTRAINT(Lang,
ErrText)), ErrText)),
@ -684,7 +684,7 @@ get_offline_els(LUser, LServer, odbc) ->
{selected, [<<"xml">>], Rs} -> {selected, [<<"xml">>], Rs} ->
lists:flatmap( lists:flatmap(
fun([XML]) -> fun([XML]) ->
case xml_stream:parse_element(XML) of case fxml_stream:parse_element(XML) of
#xmlel{} = El -> #xmlel{} = El ->
case offline_msg_to_route(LServer, El) of case offline_msg_to_route(LServer, El) of
{route, _, _, NewEl} -> {route, _, _, NewEl} ->
@ -705,8 +705,8 @@ offline_msg_to_route(LServer, #offline_msg{} = R) ->
jlib:add_delay_info(R#offline_msg.packet, LServer, R#offline_msg.timestamp, jlib:add_delay_info(R#offline_msg.packet, LServer, R#offline_msg.timestamp,
<<"Offline Storage">>)}; <<"Offline Storage">>)};
offline_msg_to_route(_LServer, #xmlel{} = El) -> offline_msg_to_route(_LServer, #xmlel{} = El) ->
To = jid:from_string(xml:get_tag_attr_s(<<"to">>, El)), To = jid:from_string(fxml:get_tag_attr_s(<<"to">>, El)),
From = jid:from_string(xml:get_tag_attr_s(<<"from">>, El)), From = jid:from_string(fxml:get_tag_attr_s(<<"from">>, El)),
if (To /= error) and (From /= error) -> if (To /= error) and (From /= error) ->
{route, From, To, El}; {route, From, To, El};
true -> true ->
@ -734,7 +734,7 @@ read_all_msgs(LUser, LServer, odbc) ->
of of
{selected, [<<"xml">>], Rs} -> {selected, [<<"xml">>], Rs} ->
lists:flatmap(fun ([XML]) -> lists:flatmap(fun ([XML]) ->
case xml_stream:parse_element(XML) of case fxml_stream:parse_element(XML) of
{error, _Reason} -> []; {error, _Reason} -> [];
El -> [El] El -> [El]
end end
@ -882,7 +882,7 @@ user_queue_parse_query(LUser, LServer, Query, odbc) ->
of of
{selected, [<<"xml">>, <<"seq">>], Rs} -> {selected, [<<"xml">>, <<"seq">>], Rs} ->
lists:flatmap(fun ([XML, Seq]) -> lists:flatmap(fun ([XML, Seq]) ->
case xml_stream:parse_element(XML) case fxml_stream:parse_element(XML)
of of
{error, _Reason} -> []; {error, _Reason} -> [];
El -> [{El, Seq}] El -> [{El, Seq}]
@ -1114,7 +1114,7 @@ export(_Server) ->
Packet1 = jlib:replace_from_to(From, To, Packet), Packet1 = jlib:replace_from_to(From, To, Packet),
Packet2 = jlib:add_delay_info(Packet1, LServer, TimeStamp, Packet2 = jlib:add_delay_info(Packet1, LServer, TimeStamp,
<<"Offline Storage">>), <<"Offline Storage">>),
XML = ejabberd_odbc:escape(xml:element_to_binary(Packet2)), XML = ejabberd_odbc:escape(fxml:element_to_binary(Packet2)),
[[<<"delete from spool where username='">>, Username, <<"';">>], [[<<"delete from spool where username='">>, Username, <<"';">>],
[<<"insert into spool(username, xml) values ('">>, [<<"insert into spool(username, xml) values ('">>,
Username, <<"', '">>, XML, <<"');">>]]; Username, <<"', '">>, XML, <<"');">>]];
@ -1125,12 +1125,12 @@ export(_Server) ->
import(LServer) -> import(LServer) ->
[{<<"select username, xml from spool;">>, [{<<"select username, xml from spool;">>,
fun([LUser, XML]) -> fun([LUser, XML]) ->
El = #xmlel{} = xml_stream:parse_element(XML), El = #xmlel{} = fxml_stream:parse_element(XML),
From = #jid{} = jid:from_string( From = #jid{} = jid:from_string(
xml:get_attr_s(<<"from">>, El#xmlel.attrs)), fxml:get_attr_s(<<"from">>, El#xmlel.attrs)),
To = #jid{} = jid:from_string( To = #jid{} = jid:from_string(
xml:get_attr_s(<<"to">>, El#xmlel.attrs)), fxml:get_attr_s(<<"to">>, El#xmlel.attrs)),
Stamp = xml:get_path_s(El, [{elem, <<"delay">>}, Stamp = fxml:get_path_s(El, [{elem, <<"delay">>},
{attr, <<"stamp">>}]), {attr, <<"stamp">>}]),
TS = case jlib:datetime_string_to_timestamp(Stamp) of TS = case jlib:datetime_string_to_timestamp(Stamp) of
{_, _, _} = Now -> {_, _, _} = Now ->

View File

@ -52,7 +52,7 @@ check_packet(_, _User, Server, _PrivacyList,
{From, To, #xmlel{name = Name, attrs = Attrs}}, Dir) -> {From, To, #xmlel{name = Name, attrs = Attrs}}, Dir) ->
case Name of case Name of
<<"presence">> -> <<"presence">> ->
IsSubscription = case xml:get_attr_s(<<"type">>, Attrs) IsSubscription = case fxml:get_attr_s(<<"type">>, Attrs)
of of
<<"subscribe">> -> true; <<"subscribe">> -> true;
<<"subscribed">> -> true; <<"subscribed">> -> true;

View File

@ -109,12 +109,12 @@ process_iq_get(_, From, _To, #iq{sub_el = SubEl},
#userlist{name = Active}) -> #userlist{name = Active}) ->
#jid{luser = LUser, lserver = LServer} = From, #jid{luser = LUser, lserver = LServer} = From,
#xmlel{children = Els} = SubEl, #xmlel{children = Els} = SubEl,
case xml:remove_cdata(Els) of case fxml:remove_cdata(Els) of
[] -> process_lists_get(LUser, LServer, Active); [] -> process_lists_get(LUser, LServer, Active);
[#xmlel{name = Name, attrs = Attrs}] -> [#xmlel{name = Name, attrs = Attrs}] ->
case Name of case Name of
<<"list">> -> <<"list">> ->
ListName = xml:get_attr(<<"name">>, Attrs), ListName = fxml:get_attr(<<"name">>, Attrs),
process_list_get(LUser, LServer, ListName); process_list_get(LUser, LServer, ListName);
_ -> {error, ?ERR_BAD_REQUEST} _ -> {error, ?ERR_BAD_REQUEST}
end; end;
@ -343,14 +343,14 @@ list_to_action(S) ->
process_iq_set(_, From, _To, #iq{sub_el = SubEl}) -> process_iq_set(_, From, _To, #iq{sub_el = SubEl}) ->
#jid{luser = LUser, lserver = LServer} = From, #jid{luser = LUser, lserver = LServer} = From,
#xmlel{children = Els} = SubEl, #xmlel{children = Els} = SubEl,
case xml:remove_cdata(Els) of case fxml:remove_cdata(Els) of
[#xmlel{name = Name, attrs = Attrs, [#xmlel{name = Name, attrs = Attrs,
children = SubEls}] -> children = SubEls}] ->
ListName = xml:get_attr(<<"name">>, Attrs), ListName = fxml:get_attr(<<"name">>, Attrs),
case Name of case Name of
<<"list">> -> <<"list">> ->
process_list_set(LUser, LServer, ListName, process_list_set(LUser, LServer, ListName,
xml:remove_cdata(SubEls)); fxml:remove_cdata(SubEls));
<<"active">> -> <<"active">> ->
process_active_set(LUser, LServer, ListName); process_active_set(LUser, LServer, ListName);
<<"default">> -> <<"default">> ->
@ -651,10 +651,10 @@ parse_items([#xmlel{name = <<"item">>, attrs = Attrs,
children = SubEls} children = SubEls}
| Els], | Els],
Res) -> Res) ->
Type = xml:get_attr(<<"type">>, Attrs), Type = fxml:get_attr(<<"type">>, Attrs),
Value = xml:get_attr(<<"value">>, Attrs), Value = fxml:get_attr(<<"value">>, Attrs),
SAction = xml:get_attr(<<"action">>, Attrs), SAction = fxml:get_attr(<<"action">>, Attrs),
SOrder = xml:get_attr(<<"order">>, Attrs), SOrder = fxml:get_attr(<<"order">>, Attrs),
Action = case catch list_to_action(element(2, SAction)) Action = case catch list_to_action(element(2, SAction))
of of
{'EXIT', _} -> false; {'EXIT', _} -> false;
@ -704,7 +704,7 @@ parse_items([#xmlel{name = <<"item">>, attrs = Attrs,
case I2 of case I2 of
false -> false; false -> false;
_ -> _ ->
case parse_matches(I2, xml:remove_cdata(SubEls)) of case parse_matches(I2, fxml:remove_cdata(SubEls)) of
false -> false; false -> false;
I3 -> parse_items(Els, [I3 | Res]) I3 -> parse_items(Els, [I3 | Res])
end end
@ -882,7 +882,7 @@ check_packet(_, User, Server,
<<"message">> -> message; <<"message">> -> message;
<<"iq">> -> iq; <<"iq">> -> iq;
<<"presence">> -> <<"presence">> ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
%% notification %% notification
<<"">> -> presence; <<"">> -> presence;
<<"unavailable">> -> presence; <<"unavailable">> -> presence;

View File

@ -125,7 +125,7 @@ filter_xmlels(Xmlels) -> filter_xmlels(Xmlels, []).
filter_xmlels([], Data) -> lists:reverse(Data); filter_xmlels([], Data) -> lists:reverse(Data);
filter_xmlels([#xmlel{attrs = Attrs} = Xmlel | Xmlels], filter_xmlels([#xmlel{attrs = Attrs} = Xmlel | Xmlels],
Data) -> Data) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
<<"">> -> []; <<"">> -> [];
XmlNS -> filter_xmlels(Xmlels, [{XmlNS, Xmlel} | Data]) XmlNS -> filter_xmlels(Xmlels, [{XmlNS, Xmlel} | Data])
end; end;
@ -154,7 +154,7 @@ set_data(LUser, LServer, {XmlNS, Xmlel}, mnesia) ->
set_data(LUser, LServer, {XMLNS, El}, odbc) -> set_data(LUser, LServer, {XMLNS, El}, odbc) ->
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
LXMLNS = ejabberd_odbc:escape(XMLNS), LXMLNS = ejabberd_odbc:escape(XMLNS),
SData = ejabberd_odbc:escape(xml:element_to_binary(El)), SData = ejabberd_odbc:escape(fxml:element_to_binary(El)),
odbc_queries:set_private_data(LServer, Username, LXMLNS, odbc_queries:set_private_data(LServer, Username, LXMLNS,
SData); SData);
set_data(LUser, LServer, {XMLNS, El}, riak) -> set_data(LUser, LServer, {XMLNS, El}, riak) ->
@ -190,7 +190,7 @@ get_data(LUser, LServer, odbc, [{XMLNS, El} | Els],
Username, LXMLNS) Username, LXMLNS)
of of
{selected, [<<"data">>], [[SData]]} -> {selected, [<<"data">>], [[SData]]} ->
case xml_stream:parse_element(SData) of case fxml_stream:parse_element(SData) of
Data when is_record(Data, xmlel) -> Data when is_record(Data, xmlel) ->
get_data(LUser, LServer, odbc, Els, [Data | Res]) get_data(LUser, LServer, odbc, Els, [Data | Res])
end; end;
@ -222,7 +222,7 @@ get_all_data(LUser, LServer, odbc) ->
{selected, [<<"namespace">>, <<"data">>], Res} -> {selected, [<<"namespace">>, <<"data">>], Res} ->
lists:flatmap( lists:flatmap(
fun([_, SData]) -> fun([_, SData]) ->
case xml_stream:parse_element(SData) of case fxml_stream:parse_element(SData) of
#xmlel{} = El -> #xmlel{} = El ->
[El]; [El];
_ -> _ ->
@ -287,7 +287,7 @@ update_table() ->
R#private_storage{usns = {iolist_to_binary(U), R#private_storage{usns = {iolist_to_binary(U),
iolist_to_binary(S), iolist_to_binary(S),
iolist_to_binary(NS)}, iolist_to_binary(NS)},
xml = xml:to_xmlel(El)} xml = fxml:to_xmlel(El)}
end); end);
_ -> _ ->
?INFO_MSG("Recreating private_storage table", []), ?INFO_MSG("Recreating private_storage table", []),
@ -302,7 +302,7 @@ export(_Server) ->
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
LXMLNS = ejabberd_odbc:escape(XMLNS), LXMLNS = ejabberd_odbc:escape(XMLNS),
SData = SData =
ejabberd_odbc:escape(xml:element_to_binary(Data)), ejabberd_odbc:escape(fxml:element_to_binary(Data)),
odbc_queries:set_private_data_sql(Username, LXMLNS, odbc_queries:set_private_data_sql(Username, LXMLNS,
SData); SData);
(_Host, _R) -> (_Host, _R) ->
@ -312,7 +312,7 @@ export(_Server) ->
import(LServer) -> import(LServer) ->
[{<<"select username, namespace, data from private_storage;">>, [{<<"select username, namespace, data from private_storage;">>,
fun([LUser, XMLNS, XML]) -> fun([LUser, XMLNS, XML]) ->
El = #xmlel{} = xml_stream:parse_element(XML), El = #xmlel{} = fxml_stream:parse_element(XML),
#private_storage{usns = {LUser, LServer, XMLNS}, #private_storage{usns = {LUser, LServer, XMLNS},
xml = El} xml = El}
end}]. end}].

View File

@ -175,11 +175,11 @@ process_iq(InitiatorJID,
#state{acl = ACL, serverhost = ServerHost}) -> #state{acl = ACL, serverhost = ServerHost}) ->
case acl:match_rule(ServerHost, ACL, InitiatorJID) of case acl:match_rule(ServerHost, ACL, InitiatorJID) of
allow -> allow ->
ActivateEl = xml:get_path_s(SubEl, ActivateEl = fxml:get_path_s(SubEl,
[{elem, <<"activate">>}]), [{elem, <<"activate">>}]),
SID = xml:get_tag_attr_s(<<"sid">>, SubEl), SID = fxml:get_tag_attr_s(<<"sid">>, SubEl),
case catch case catch
jid:from_string(xml:get_tag_cdata(ActivateEl)) jid:from_string(fxml:get_tag_cdata(ActivateEl))
of of
TargetJID TargetJID
when is_record(TargetJID, jid), SID /= <<"">>, when is_record(TargetJID, jid), SID /= <<"">>,

View File

@ -951,7 +951,7 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) ->
case jlib:iq_query_info(Packet) of case jlib:iq_query_info(Packet) of
#iq{type = get, xmlns = ?NS_DISCO_INFO, sub_el = SubEl, lang = Lang} = IQ -> #iq{type = get, xmlns = ?NS_DISCO_INFO, sub_el = SubEl, lang = Lang} = IQ ->
#xmlel{attrs = QAttrs} = SubEl, #xmlel{attrs = QAttrs} = SubEl,
Node = xml:get_attr_s(<<"node">>, QAttrs), Node = fxml:get_attr_s(<<"node">>, QAttrs),
Info = ejabberd_hooks:run_fold(disco_info, ServerHost, Info = ejabberd_hooks:run_fold(disco_info, ServerHost,
[], [],
[ServerHost, ?MODULE, <<>>, <<>>]), [ServerHost, ?MODULE, <<>>, <<>>]),
@ -968,7 +968,7 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) ->
ejabberd_router:route(To, From, Res); ejabberd_router:route(To, From, Res);
#iq{type = get, xmlns = ?NS_DISCO_ITEMS, sub_el = SubEl} = IQ -> #iq{type = get, xmlns = ?NS_DISCO_ITEMS, sub_el = SubEl} = IQ ->
#xmlel{attrs = QAttrs} = SubEl, #xmlel{attrs = QAttrs} = SubEl,
Node = xml:get_attr_s(<<"node">>, QAttrs), Node = fxml:get_attr_s(<<"node">>, QAttrs),
Res = case iq_disco_items(Host, Node, From, jlib:rsm_decode(IQ)) of Res = case iq_disco_items(Host, Node, From, jlib:rsm_decode(IQ)) of
{result, IQRes} -> {result, IQRes} ->
jlib:iq_to_xml(IQ#iq{type = result, jlib:iq_to_xml(IQ#iq{type = result,
@ -1022,7 +1022,7 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) ->
ok ok
end; end;
<<"message">> -> <<"message">> ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"error">> -> <<"error">> ->
ok; ok;
_ -> _ ->
@ -1040,7 +1040,7 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) ->
ok ok
end; end;
_ -> _ ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<"error">> -> <<"error">> ->
ok; ok;
<<"result">> -> <<"result">> ->
@ -1255,16 +1255,16 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang) ->
iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) -> iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) ->
#xmlel{children = SubEls} = SubEl, #xmlel{children = SubEls} = SubEl,
case xml:remove_cdata(SubEls) of case fxml:remove_cdata(SubEls) of
[#xmlel{name = Name, attrs = Attrs, children = Els} | Rest] -> [#xmlel{name = Name, attrs = Attrs, children = Els} | Rest] ->
Node = xml:get_attr_s(<<"node">>, Attrs), Node = fxml:get_attr_s(<<"node">>, Attrs),
case {IQType, Name} of case {IQType, Name} of
{set, <<"create">>} -> {set, <<"create">>} ->
Config = case Rest of Config = case Rest of
[#xmlel{name = <<"configure">>, children = C}] -> C; [#xmlel{name = <<"configure">>, children = C}] -> C;
_ -> [] _ -> []
end, end,
Type = case xml:get_attr_s(<<"type">>, Attrs) of Type = case fxml:get_attr_s(<<"type">>, Attrs) of
<<>> -> hd(Plugins); <<>> -> hd(Plugins);
T -> T T -> T
end, end,
@ -1276,10 +1276,10 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) ->
create_node(Host, ServerHost, Node, From, Type, Access, Config) create_node(Host, ServerHost, Node, From, Type, Access, Config)
end; end;
{set, <<"publish">>} -> {set, <<"publish">>} ->
case xml:remove_cdata(Els) of case fxml:remove_cdata(Els) of
[#xmlel{name = <<"item">>, attrs = ItemAttrs, [#xmlel{name = <<"item">>, attrs = ItemAttrs,
children = Payload}] -> children = Payload}] ->
ItemId = xml:get_attr_s(<<"id">>, ItemAttrs), ItemId = fxml:get_attr_s(<<"id">>, ItemAttrs),
publish_item(Host, ServerHost, Node, From, ItemId, Payload, Access); publish_item(Host, ServerHost, Node, From, ItemId, Payload, Access);
[] -> [] ->
{error, {error,
@ -1289,14 +1289,14 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) ->
extended_error(?ERR_BAD_REQUEST, <<"invalid-payload">>)} extended_error(?ERR_BAD_REQUEST, <<"invalid-payload">>)}
end; end;
{set, <<"retract">>} -> {set, <<"retract">>} ->
ForceNotify = case xml:get_attr_s(<<"notify">>, Attrs) of ForceNotify = case fxml:get_attr_s(<<"notify">>, Attrs) of
<<"1">> -> true; <<"1">> -> true;
<<"true">> -> true; <<"true">> -> true;
_ -> false _ -> false
end, end,
case xml:remove_cdata(Els) of case fxml:remove_cdata(Els) of
[#xmlel{name = <<"item">>, attrs = ItemAttrs}] -> [#xmlel{name = <<"item">>, attrs = ItemAttrs}] ->
ItemId = xml:get_attr_s(<<"id">>, ItemAttrs), ItemId = fxml:get_attr_s(<<"id">>, ItemAttrs),
delete_item(Host, Node, From, ItemId, ForceNotify); delete_item(Host, Node, From, ItemId, ForceNotify);
_ -> _ ->
{error, {error,
@ -1307,37 +1307,37 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) ->
[#xmlel{name = <<"options">>, children = C}] -> C; [#xmlel{name = <<"options">>, children = C}] -> C;
_ -> [] _ -> []
end, end,
JID = xml:get_attr_s(<<"jid">>, Attrs), JID = fxml:get_attr_s(<<"jid">>, Attrs),
subscribe_node(Host, Node, From, JID, Config); subscribe_node(Host, Node, From, JID, Config);
{set, <<"unsubscribe">>} -> {set, <<"unsubscribe">>} ->
JID = xml:get_attr_s(<<"jid">>, Attrs), JID = fxml:get_attr_s(<<"jid">>, Attrs),
SubId = xml:get_attr_s(<<"subid">>, Attrs), SubId = fxml:get_attr_s(<<"subid">>, Attrs),
unsubscribe_node(Host, Node, From, JID, SubId); unsubscribe_node(Host, Node, From, JID, SubId);
{get, <<"items">>} -> {get, <<"items">>} ->
MaxItems = xml:get_attr_s(<<"max_items">>, Attrs), MaxItems = fxml:get_attr_s(<<"max_items">>, Attrs),
SubId = xml:get_attr_s(<<"subid">>, Attrs), SubId = fxml:get_attr_s(<<"subid">>, Attrs),
ItemIds = lists:foldl(fun ItemIds = lists:foldl(fun
(#xmlel{name = <<"item">>, attrs = ItemAttrs}, Acc) -> (#xmlel{name = <<"item">>, attrs = ItemAttrs}, Acc) ->
case xml:get_attr_s(<<"id">>, ItemAttrs) of case fxml:get_attr_s(<<"id">>, ItemAttrs) of
<<>> -> Acc; <<>> -> Acc;
ItemId -> [ItemId | Acc] ItemId -> [ItemId | Acc]
end; end;
(_, Acc) -> (_, Acc) ->
Acc Acc
end, end,
[], xml:remove_cdata(Els)), [], fxml:remove_cdata(Els)),
get_items(Host, Node, From, SubId, MaxItems, ItemIds, jlib:rsm_decode(SubEl)); get_items(Host, Node, From, SubId, MaxItems, ItemIds, jlib:rsm_decode(SubEl));
{get, <<"subscriptions">>} -> {get, <<"subscriptions">>} ->
get_subscriptions(Host, Node, From, Plugins); get_subscriptions(Host, Node, From, Plugins);
{get, <<"affiliations">>} -> {get, <<"affiliations">>} ->
get_affiliations(Host, Node, From, Plugins); get_affiliations(Host, Node, From, Plugins);
{get, <<"options">>} -> {get, <<"options">>} ->
SubId = xml:get_attr_s(<<"subid">>, Attrs), SubId = fxml:get_attr_s(<<"subid">>, Attrs),
JID = xml:get_attr_s(<<"jid">>, Attrs), JID = fxml:get_attr_s(<<"jid">>, Attrs),
get_options(Host, Node, JID, SubId, Lang); get_options(Host, Node, JID, SubId, Lang);
{set, <<"options">>} -> {set, <<"options">>} ->
SubId = xml:get_attr_s(<<"subid">>, Attrs), SubId = fxml:get_attr_s(<<"subid">>, Attrs),
JID = xml:get_attr_s(<<"jid">>, Attrs), JID = fxml:get_attr_s(<<"jid">>, Attrs),
set_options(Host, Node, JID, SubId, Els); set_options(Host, Node, JID, SubId, Els);
_ -> _ ->
{error, ?ERR_FEATURE_NOT_IMPLEMENTED} {error, ?ERR_FEATURE_NOT_IMPLEMENTED}
@ -1362,10 +1362,10 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) ->
). ).
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) -> iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
#xmlel{children = SubEls} = SubEl, #xmlel{children = SubEls} = SubEl,
Action = xml:remove_cdata(SubEls), Action = fxml:remove_cdata(SubEls),
case Action of case Action of
[#xmlel{name = Name, attrs = Attrs, children = Els}] -> [#xmlel{name = Name, attrs = Attrs, children = Els}] ->
Node = xml:get_attr_s(<<"node">>, Attrs), Node = fxml:get_attr_s(<<"node">>, Attrs),
case {IQType, Name} of case {IQType, Name} of
{get, <<"configure">>} -> {get, <<"configure">>} ->
get_configure(Host, ServerHost, Node, From, Lang); get_configure(Host, ServerHost, Node, From, Lang);
@ -1380,11 +1380,11 @@ iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
{get, <<"subscriptions">>} -> {get, <<"subscriptions">>} ->
get_subscriptions(Host, Node, From); get_subscriptions(Host, Node, From);
{set, <<"subscriptions">>} -> {set, <<"subscriptions">>} ->
set_subscriptions(Host, Node, From, xml:remove_cdata(Els)); set_subscriptions(Host, Node, From, fxml:remove_cdata(Els));
{get, <<"affiliations">>} -> {get, <<"affiliations">>} ->
get_affiliations(Host, Node, From); get_affiliations(Host, Node, From);
{set, <<"affiliations">>} -> {set, <<"affiliations">>} ->
set_affiliations(Host, Node, From, xml:remove_cdata(Els)); set_affiliations(Host, Node, From, fxml:remove_cdata(Els));
_ -> _ ->
{error, ?ERR_FEATURE_NOT_IMPLEMENTED} {error, ?ERR_FEATURE_NOT_IMPLEMENTED}
end; end;
@ -1597,9 +1597,9 @@ find_authorization_response(Packet) ->
#xmlel{children = Els} = Packet, #xmlel{children = Els} = Packet,
XData1 = lists:map(fun XData1 = lists:map(fun
(#xmlel{name = <<"x">>, attrs = XAttrs} = XEl) -> (#xmlel{name = <<"x">>, attrs = XAttrs} = XEl) ->
case xml:get_attr_s(<<"xmlns">>, XAttrs) of case fxml:get_attr_s(<<"xmlns">>, XAttrs) of
?NS_XDATA -> ?NS_XDATA ->
case xml:get_attr_s(<<"type">>, XAttrs) of case fxml:get_attr_s(<<"type">>, XAttrs) of
<<"cancel">> -> none; <<"cancel">> -> none;
_ -> jlib:parse_xdata_submit(XEl) _ -> jlib:parse_xdata_submit(XEl)
end; end;
@ -1609,7 +1609,7 @@ find_authorization_response(Packet) ->
(_) -> (_) ->
none none
end, end,
xml:remove_cdata(Els)), fxml:remove_cdata(Els)),
XData = lists:filter(fun (E) -> E /= none end, XData1), XData = lists:filter(fun (E) -> E /= none end, XData1),
case XData of case XData of
[invalid] -> [invalid] ->
@ -1808,7 +1808,7 @@ create_node(Host, ServerHost, <<>>, Owner, Type, Access, Configuration) ->
end; end;
create_node(Host, ServerHost, Node, Owner, GivenType, Access, Configuration) -> create_node(Host, ServerHost, Node, Owner, GivenType, Access, Configuration) ->
Type = select_type(ServerHost, Host, Node, GivenType), Type = select_type(ServerHost, Host, Node, GivenType),
ParseOptions = case xml:remove_cdata(Configuration) of ParseOptions = case fxml:remove_cdata(Configuration) of
[] -> [] ->
{result, node_options(Host, Type)}; {result, node_options(Host, Type)};
[#xmlel{name = <<"x">>} = XEl] -> [#xmlel{name = <<"x">>} = XEl] ->
@ -2668,8 +2668,8 @@ set_affiliations(Host, Node, From, EntitiesEls) ->
(El, Acc) -> (El, Acc) ->
case El of case El of
#xmlel{name = <<"affiliation">>, attrs = Attrs} -> #xmlel{name = <<"affiliation">>, attrs = Attrs} ->
JID = jid:from_string(xml:get_attr_s(<<"jid">>, Attrs)), JID = jid:from_string(fxml:get_attr_s(<<"jid">>, Attrs)),
Affiliation = string_to_affiliation(xml:get_attr_s(<<"affiliation">>, Attrs)), Affiliation = string_to_affiliation(fxml:get_attr_s(<<"affiliation">>, Attrs)),
if (JID == error) or (Affiliation == false) -> error; if (JID == error) or (Affiliation == false) -> error;
true -> [{jid:tolower(JID), Affiliation} | Acc] true -> [{jid:tolower(JID), Affiliation} | Acc]
end end
@ -2998,9 +2998,9 @@ set_subscriptions(Host, Node, From, EntitiesEls) ->
(El, Acc) -> (El, Acc) ->
case El of case El of
#xmlel{name = <<"subscription">>, attrs = Attrs} -> #xmlel{name = <<"subscription">>, attrs = Attrs} ->
JID = jid:from_string(xml:get_attr_s(<<"jid">>, Attrs)), JID = jid:from_string(fxml:get_attr_s(<<"jid">>, Attrs)),
Sub = string_to_subscription(xml:get_attr_s(<<"subscription">>, Attrs)), Sub = string_to_subscription(fxml:get_attr_s(<<"subscription">>, Attrs)),
SubId = xml:get_attr_s(<<"subid">>, Attrs), SubId = fxml:get_attr_s(<<"subid">>, Attrs),
if (JID == error) or (Sub == false) -> error; if (JID == error) or (Sub == false) -> error;
true -> [{jid:tolower(JID), Sub, SubId} | Acc] true -> [{jid:tolower(JID), Sub, SubId} | Acc]
end end
@ -3786,9 +3786,9 @@ get_configure_xfields(_Type, Options, Lang, Groups) ->
%%<li>The specified node does not exist.</li> %%<li>The specified node does not exist.</li>
%%</ul> %%</ul>
set_configure(Host, Node, From, Els, Lang) -> set_configure(Host, Node, From, Els, Lang) ->
case xml:remove_cdata(Els) of case fxml:remove_cdata(Els) of
[#xmlel{name = <<"x">>} = XEl] -> [#xmlel{name = <<"x">>} = XEl] ->
case {xml:get_tag_attr_s(<<"xmlns">>, XEl), xml:get_tag_attr_s(<<"type">>, XEl)} of case {fxml:get_tag_attr_s(<<"xmlns">>, XEl), fxml:get_tag_attr_s(<<"type">>, XEl)} of
{?NS_XDATA, <<"cancel">>} -> {?NS_XDATA, <<"cancel">>} ->
{result, []}; {result, []};
{?NS_XDATA, <<"submit">>} -> {?NS_XDATA, <<"submit">>} ->

View File

@ -121,9 +121,9 @@ process_iq(From, To,
end, end,
case Type of case Type of
set -> set ->
UTag = xml:get_subtag(SubEl, <<"username">>), UTag = fxml:get_subtag(SubEl, <<"username">>),
PTag = xml:get_subtag(SubEl, <<"password">>), PTag = fxml:get_subtag(SubEl, <<"password">>),
RTag = xml:get_subtag(SubEl, <<"remove">>), RTag = fxml:get_subtag(SubEl, <<"remove">>),
Server = To#jid.lserver, Server = To#jid.lserver,
Access = gen_mod:get_module_opt(Server, ?MODULE, access, Access = gen_mod:get_module_opt(Server, ?MODULE, access,
fun(A) when is_atom(A) -> A end, fun(A) when is_atom(A) -> A end,
@ -132,14 +132,14 @@ process_iq(From, To,
acl:match_rule(Server, Access, From), acl:match_rule(Server, Access, From),
if (UTag /= false) and (RTag /= false) and if (UTag /= false) and (RTag /= false) and
AllowRemove -> AllowRemove ->
User = xml:get_tag_cdata(UTag), User = fxml:get_tag_cdata(UTag),
case From of case From of
#jid{user = User, lserver = Server} -> #jid{user = User, lserver = Server} ->
ejabberd_auth:remove_user(User, Server), ejabberd_auth:remove_user(User, Server),
IQ#iq{type = result, sub_el = []}; IQ#iq{type = result, sub_el = []};
_ -> _ ->
if PTag /= false -> if PTag /= false ->
Password = xml:get_tag_cdata(PTag), Password = fxml:get_tag_cdata(PTag),
case ejabberd_auth:remove_user(User, Server, case ejabberd_auth:remove_user(User, Server,
Password) Password)
of of
@ -185,8 +185,8 @@ process_iq(From, To,
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]} IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]}
end; end;
(UTag /= false) and (PTag /= false) -> (UTag /= false) and (PTag /= false) ->
User = xml:get_tag_cdata(UTag), User = fxml:get_tag_cdata(UTag),
Password = xml:get_tag_cdata(PTag), Password = fxml:get_tag_cdata(PTag),
try_register_or_set_password(User, Server, Password, try_register_or_set_password(User, Server, Password,
From, IQ, SubEl, Source, Lang, From, IQ, SubEl, Source, Lang,
not IsCaptchaEnabled); not IsCaptchaEnabled);
@ -599,7 +599,7 @@ write_time({{Y, Mo, D}, {H, Mi, S}}) ->
[Y, Mo, D, H, Mi, S]). [Y, Mo, D, H, Mi, S]).
process_xdata_submit(El) -> process_xdata_submit(El) ->
case xml:get_subtag(El, <<"x">>) of case fxml:get_subtag(El, <<"x">>) of
false -> error; false -> error;
Xdata -> Xdata ->
Fields = jlib:parse_xdata_submit(Xdata), Fields = jlib:parse_xdata_submit(Xdata),

View File

@ -267,7 +267,7 @@ process_iq_get(From, To, #iq{sub_el = SubEl} = IQ) ->
LServer = From#jid.lserver, LServer = From#jid.lserver,
US = {LUser, LServer}, US = {LUser, LServer},
try {ItemsToSend, VersionToSend} = case try {ItemsToSend, VersionToSend} = case
{xml:get_tag_attr(<<"ver">>, SubEl), {fxml:get_tag_attr(<<"ver">>, SubEl),
roster_versioning_enabled(LServer), roster_versioning_enabled(LServer),
roster_version_on_db(LServer)} roster_version_on_db(LServer)}
of of
@ -516,7 +516,7 @@ process_iq_set(From, To, #iq{sub_el = SubEl, id = Id} = IQ) ->
process_item_set(From, To, process_item_set(From, To,
#xmlel{attrs = Attrs, children = Els}, Managed) -> #xmlel{attrs = Attrs, children = Els}, Managed) ->
JID1 = jid:from_string(xml:get_attr_s(<<"jid">>, JID1 = jid:from_string(fxml:get_attr_s(<<"jid">>,
Attrs)), Attrs)),
#jid{user = User, luser = LUser, lserver = LServer} = #jid{user = User, luser = LUser, lserver = LServer} =
From, From,
@ -585,10 +585,10 @@ process_item_els(Item,
| Els]) -> | Els]) ->
case Name of case Name of
<<"group">> -> <<"group">> ->
Groups = [xml:get_cdata(SEls) | Item#roster.groups], Groups = [fxml:get_cdata(SEls) | Item#roster.groups],
process_item_els(Item#roster{groups = Groups}, Els); process_item_els(Item#roster{groups = Groups}, Els);
_ -> _ ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
<<"">> -> process_item_els(Item, Els); <<"">> -> process_item_els(Item, Els);
_ -> _ ->
XEls = [#xmlel{name = Name, attrs = Attrs, XEls = [#xmlel{name = Name, attrs = Attrs,
@ -1089,7 +1089,7 @@ del_roster_t(LUser, LServer, LJID, riak) ->
process_item_set_t(LUser, LServer, process_item_set_t(LUser, LServer,
#xmlel{attrs = Attrs, children = Els}) -> #xmlel{attrs = Attrs, children = Els}) ->
JID1 = jid:from_string(xml:get_attr_s(<<"jid">>, JID1 = jid:from_string(fxml:get_attr_s(<<"jid">>,
Attrs)), Attrs)),
case JID1 of case JID1 of
error -> ok; error -> ok;
@ -1390,7 +1390,7 @@ update_roster_table() ->
groups = [iolist_to_binary(G) || G <- Gs], groups = [iolist_to_binary(G) || G <- Gs],
askmessage = try iolist_to_binary(Ask) askmessage = try iolist_to_binary(Ask)
catch _:_ -> <<"">> end, catch _:_ -> <<"">> end,
xs = [xml:to_xmlel(X) || X <- Xs]} xs = [fxml:to_xmlel(X) || X <- Xs]}
end); end);
_ -> _ ->
?INFO_MSG("Recreating roster table", []), ?INFO_MSG("Recreating roster table", []),

View File

@ -206,11 +206,11 @@ get_rosteritem_name([ModVcard], U, S) ->
get_rosteritem_name_vcard([]) -> <<"">>; get_rosteritem_name_vcard([]) -> <<"">>;
get_rosteritem_name_vcard([Vcard]) -> get_rosteritem_name_vcard([Vcard]) ->
case xml:get_path_s(Vcard, case fxml:get_path_s(Vcard,
[{elem, <<"NICKNAME">>}, cdata]) [{elem, <<"NICKNAME">>}, cdata])
of of
<<"">> -> <<"">> ->
xml:get_path_s(Vcard, [{elem, <<"FN">>}, cdata]); fxml:get_path_s(Vcard, [{elem, <<"FN">>}, cdata]);
Nickname -> Nickname Nickname -> Nickname
end. end.

View File

@ -57,7 +57,7 @@ process_local_iq(_From, To,
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]}; IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]};
get -> get ->
#xmlel{children = Els} = SubEl, #xmlel{children = Els} = SubEl,
Node = str:tokens(xml:get_tag_attr_s(<<"node">>, SubEl), Node = str:tokens(fxml:get_tag_attr_s(<<"node">>, SubEl),
<<"/">>), <<"/">>),
Names = get_names(Els, []), Names = get_names(Els, []),
case get_local_stats(To#jid.server, Node, Names) of case get_local_stats(To#jid.server, Node, Names) of
@ -76,7 +76,7 @@ get_names([], Res) -> Res;
get_names([#xmlel{name = <<"stat">>, attrs = Attrs} get_names([#xmlel{name = <<"stat">>, attrs = Attrs}
| Els], | Els],
Res) -> Res) ->
Name = xml:get_attr_s(<<"name">>, Attrs), Name = fxml:get_attr_s(<<"name">>, Attrs),
case Name of case Name of
<<"">> -> get_names(Els, Res); <<"">> -> get_names(Els, Res);
_ -> get_names(Els, [Name | Res]) _ -> get_names(Els, [Name | Res])

View File

@ -215,7 +215,7 @@ get_vcard(LUser, LServer, odbc) ->
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
case catch odbc_queries:get_vcard(LServer, Username) of case catch odbc_queries:get_vcard(LServer, Username) of
{selected, [<<"vcard">>], [[SVCARD]]} -> {selected, [<<"vcard">>], [[SVCARD]]} ->
case xml_stream:parse_element(SVCARD) of case fxml_stream:parse_element(SVCARD) of
{error, _Reason} -> error; {error, _Reason} -> error;
VCARD -> [VCARD] VCARD -> [VCARD]
end; end;
@ -233,29 +233,29 @@ get_vcard(LUser, LServer, riak) ->
end. end.
set_vcard(User, LServer, VCARD) -> set_vcard(User, LServer, VCARD) ->
FN = xml:get_path_s(VCARD, [{elem, <<"FN">>}, cdata]), FN = fxml:get_path_s(VCARD, [{elem, <<"FN">>}, cdata]),
Family = xml:get_path_s(VCARD, Family = fxml:get_path_s(VCARD,
[{elem, <<"N">>}, {elem, <<"FAMILY">>}, cdata]), [{elem, <<"N">>}, {elem, <<"FAMILY">>}, cdata]),
Given = xml:get_path_s(VCARD, Given = fxml:get_path_s(VCARD,
[{elem, <<"N">>}, {elem, <<"GIVEN">>}, cdata]), [{elem, <<"N">>}, {elem, <<"GIVEN">>}, cdata]),
Middle = xml:get_path_s(VCARD, Middle = fxml:get_path_s(VCARD,
[{elem, <<"N">>}, {elem, <<"MIDDLE">>}, cdata]), [{elem, <<"N">>}, {elem, <<"MIDDLE">>}, cdata]),
Nickname = xml:get_path_s(VCARD, Nickname = fxml:get_path_s(VCARD,
[{elem, <<"NICKNAME">>}, cdata]), [{elem, <<"NICKNAME">>}, cdata]),
BDay = xml:get_path_s(VCARD, BDay = fxml:get_path_s(VCARD,
[{elem, <<"BDAY">>}, cdata]), [{elem, <<"BDAY">>}, cdata]),
CTRY = xml:get_path_s(VCARD, CTRY = fxml:get_path_s(VCARD,
[{elem, <<"ADR">>}, {elem, <<"CTRY">>}, cdata]), [{elem, <<"ADR">>}, {elem, <<"CTRY">>}, cdata]),
Locality = xml:get_path_s(VCARD, Locality = fxml:get_path_s(VCARD,
[{elem, <<"ADR">>}, {elem, <<"LOCALITY">>}, [{elem, <<"ADR">>}, {elem, <<"LOCALITY">>},
cdata]), cdata]),
EMail1 = xml:get_path_s(VCARD, EMail1 = fxml:get_path_s(VCARD,
[{elem, <<"EMAIL">>}, {elem, <<"USERID">>}, cdata]), [{elem, <<"EMAIL">>}, {elem, <<"USERID">>}, cdata]),
EMail2 = xml:get_path_s(VCARD, EMail2 = fxml:get_path_s(VCARD,
[{elem, <<"EMAIL">>}, cdata]), [{elem, <<"EMAIL">>}, cdata]),
OrgName = xml:get_path_s(VCARD, OrgName = fxml:get_path_s(VCARD,
[{elem, <<"ORG">>}, {elem, <<"ORGNAME">>}, cdata]), [{elem, <<"ORG">>}, {elem, <<"ORGNAME">>}, cdata]),
OrgUnit = xml:get_path_s(VCARD, OrgUnit = fxml:get_path_s(VCARD,
[{elem, <<"ORG">>}, {elem, <<"ORGUNIT">>}, cdata]), [{elem, <<"ORG">>}, {elem, <<"ORGUNIT">>}, cdata]),
EMail = case EMail1 of EMail = case EMail1 of
<<"">> -> EMail2; <<"">> -> EMail2;
@ -339,7 +339,7 @@ set_vcard(User, LServer, VCARD) ->
Username = ejabberd_odbc:escape(User), Username = ejabberd_odbc:escape(User),
LUsername = ejabberd_odbc:escape(LUser), LUsername = ejabberd_odbc:escape(LUser),
SVCARD = SVCARD =
ejabberd_odbc:escape(xml:element_to_binary(VCARD)), ejabberd_odbc:escape(fxml:element_to_binary(VCARD)),
SFN = ejabberd_odbc:escape(FN), SFN = ejabberd_odbc:escape(FN),
SLFN = ejabberd_odbc:escape(LFN), SLFN = ejabberd_odbc:escape(LFN),
SFamily = ejabberd_odbc:escape(Family), SFamily = ejabberd_odbc:escape(Family),
@ -587,7 +587,7 @@ find_xdata_el1([]) -> false;
find_xdata_el1([#xmlel{name = Name, attrs = Attrs, find_xdata_el1([#xmlel{name = Name, attrs = Attrs,
children = SubEls} children = SubEls}
| Els]) -> | Els]) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_XDATA -> ?NS_XDATA ->
#xmlel{name = Name, attrs = Attrs, children = SubEls}; #xmlel{name = Name, attrs = Attrs, children = SubEls};
_ -> find_xdata_el1(Els) _ -> find_xdata_el1(Els)
@ -862,27 +862,27 @@ set_vcard_t(R, _) ->
US = R#vcard.us, US = R#vcard.us,
User = US, User = US,
VCARD = R#vcard.vcard, VCARD = R#vcard.vcard,
FN = xml:get_path_s(VCARD, [{elem, <<"FN">>}, cdata]), FN = fxml:get_path_s(VCARD, [{elem, <<"FN">>}, cdata]),
Family = xml:get_path_s(VCARD, Family = fxml:get_path_s(VCARD,
[{elem, <<"N">>}, {elem, <<"FAMILY">>}, cdata]), [{elem, <<"N">>}, {elem, <<"FAMILY">>}, cdata]),
Given = xml:get_path_s(VCARD, Given = fxml:get_path_s(VCARD,
[{elem, <<"N">>}, {elem, <<"GIVEN">>}, cdata]), [{elem, <<"N">>}, {elem, <<"GIVEN">>}, cdata]),
Middle = xml:get_path_s(VCARD, Middle = fxml:get_path_s(VCARD,
[{elem, <<"N">>}, {elem, <<"MIDDLE">>}, cdata]), [{elem, <<"N">>}, {elem, <<"MIDDLE">>}, cdata]),
Nickname = xml:get_path_s(VCARD, Nickname = fxml:get_path_s(VCARD,
[{elem, <<"NICKNAME">>}, cdata]), [{elem, <<"NICKNAME">>}, cdata]),
BDay = xml:get_path_s(VCARD, BDay = fxml:get_path_s(VCARD,
[{elem, <<"BDAY">>}, cdata]), [{elem, <<"BDAY">>}, cdata]),
CTRY = xml:get_path_s(VCARD, CTRY = fxml:get_path_s(VCARD,
[{elem, <<"ADR">>}, {elem, <<"CTRY">>}, cdata]), [{elem, <<"ADR">>}, {elem, <<"CTRY">>}, cdata]),
Locality = xml:get_path_s(VCARD, Locality = fxml:get_path_s(VCARD,
[{elem, <<"ADR">>}, {elem, <<"LOCALITY">>}, [{elem, <<"ADR">>}, {elem, <<"LOCALITY">>},
cdata]), cdata]),
EMail = xml:get_path_s(VCARD, EMail = fxml:get_path_s(VCARD,
[{elem, <<"EMAIL">>}, cdata]), [{elem, <<"EMAIL">>}, cdata]),
OrgName = xml:get_path_s(VCARD, OrgName = fxml:get_path_s(VCARD,
[{elem, <<"ORG">>}, {elem, <<"ORGNAME">>}, cdata]), [{elem, <<"ORG">>}, {elem, <<"ORGNAME">>}, cdata]),
OrgUnit = xml:get_path_s(VCARD, OrgUnit = fxml:get_path_s(VCARD,
[{elem, <<"ORG">>}, {elem, <<"ORGUNIT">>}, cdata]), [{elem, <<"ORG">>}, {elem, <<"ORGUNIT">>}, cdata]),
{LUser, _LServer} = US, {LUser, _LServer} = US,
LFN = string2lower(FN), LFN = string2lower(FN),
@ -952,7 +952,7 @@ update_vcard_table() ->
fun(#vcard{us = {U, S}, vcard = El} = R) -> fun(#vcard{us = {U, S}, vcard = El} = R) ->
R#vcard{us = {iolist_to_binary(U), R#vcard{us = {iolist_to_binary(U),
iolist_to_binary(S)}, iolist_to_binary(S)},
vcard = xml:to_xmlel(El)} vcard = fxml:to_xmlel(El)}
end); end);
_ -> _ ->
?INFO_MSG("Recreating vcard table", []), ?INFO_MSG("Recreating vcard table", []),
@ -991,7 +991,7 @@ export(_Server) ->
when LServer == Host -> when LServer == Host ->
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
SVCARD = SVCARD =
ejabberd_odbc:escape(xml:element_to_binary(VCARD)), ejabberd_odbc:escape(fxml:element_to_binary(VCARD)),
[[<<"delete from vcard where username='">>, Username, <<"';">>], [[<<"delete from vcard where username='">>, Username, <<"';">>],
[<<"insert into vcard(username, vcard) values ('">>, [<<"insert into vcard(username, vcard) values ('">>,
Username, <<"', '">>, SVCARD, <<"');">>]]; Username, <<"', '">>, SVCARD, <<"');">>]];
@ -1064,7 +1064,7 @@ export(_Server) ->
import(LServer) -> import(LServer) ->
[{<<"select username, vcard from vcard;">>, [{<<"select username, vcard from vcard;">>,
fun([LUser, SVCard]) -> fun([LUser, SVCard]) ->
#xmlel{} = VCARD = xml_stream:parse_element(SVCard), #xmlel{} = VCARD = fxml_stream:parse_element(SVCard),
#vcard{us = {LUser, LServer}, vcard = VCARD} #vcard{us = {LUser, LServer}, vcard = VCARD}
end}, end},
{<<"select username, lusername, fn, lfn, family, lfamily, " {<<"select username, lusername, fn, lfn, family, lfamily, "
@ -1095,29 +1095,29 @@ import(_LServer, mnesia, #vcard{} = VCard) ->
import(_LServer, mnesia, #vcard_search{} = S) -> import(_LServer, mnesia, #vcard_search{} = S) ->
mnesia:dirty_write(S); mnesia:dirty_write(S);
import(_LServer, riak, #vcard{us = {LUser, _}, vcard = El} = VCard) -> import(_LServer, riak, #vcard{us = {LUser, _}, vcard = El} = VCard) ->
FN = xml:get_path_s(El, [{elem, <<"FN">>}, cdata]), FN = fxml:get_path_s(El, [{elem, <<"FN">>}, cdata]),
Family = xml:get_path_s(El, Family = fxml:get_path_s(El,
[{elem, <<"N">>}, {elem, <<"FAMILY">>}, cdata]), [{elem, <<"N">>}, {elem, <<"FAMILY">>}, cdata]),
Given = xml:get_path_s(El, Given = fxml:get_path_s(El,
[{elem, <<"N">>}, {elem, <<"GIVEN">>}, cdata]), [{elem, <<"N">>}, {elem, <<"GIVEN">>}, cdata]),
Middle = xml:get_path_s(El, Middle = fxml:get_path_s(El,
[{elem, <<"N">>}, {elem, <<"MIDDLE">>}, cdata]), [{elem, <<"N">>}, {elem, <<"MIDDLE">>}, cdata]),
Nickname = xml:get_path_s(El, Nickname = fxml:get_path_s(El,
[{elem, <<"NICKNAME">>}, cdata]), [{elem, <<"NICKNAME">>}, cdata]),
BDay = xml:get_path_s(El, BDay = fxml:get_path_s(El,
[{elem, <<"BDAY">>}, cdata]), [{elem, <<"BDAY">>}, cdata]),
CTRY = xml:get_path_s(El, CTRY = fxml:get_path_s(El,
[{elem, <<"ADR">>}, {elem, <<"CTRY">>}, cdata]), [{elem, <<"ADR">>}, {elem, <<"CTRY">>}, cdata]),
Locality = xml:get_path_s(El, Locality = fxml:get_path_s(El,
[{elem, <<"ADR">>}, {elem, <<"LOCALITY">>}, [{elem, <<"ADR">>}, {elem, <<"LOCALITY">>},
cdata]), cdata]),
EMail1 = xml:get_path_s(El, EMail1 = fxml:get_path_s(El,
[{elem, <<"EMAIL">>}, {elem, <<"USERID">>}, cdata]), [{elem, <<"EMAIL">>}, {elem, <<"USERID">>}, cdata]),
EMail2 = xml:get_path_s(El, EMail2 = fxml:get_path_s(El,
[{elem, <<"EMAIL">>}, cdata]), [{elem, <<"EMAIL">>}, cdata]),
OrgName = xml:get_path_s(El, OrgName = fxml:get_path_s(El,
[{elem, <<"ORG">>}, {elem, <<"ORGNAME">>}, cdata]), [{elem, <<"ORG">>}, {elem, <<"ORGNAME">>}, cdata]),
OrgUnit = xml:get_path_s(El, OrgUnit = fxml:get_path_s(El,
[{elem, <<"ORG">>}, {elem, <<"ORGUNIT">>}, cdata]), [{elem, <<"ORG">>}, {elem, <<"ORGUNIT">>}, cdata]),
EMail = case EMail1 of EMail = case EMail1 of
<<"">> -> EMail2; <<"">> -> EMail2;

View File

@ -21,7 +21,7 @@
%%% with this program; if not, write to the Free Software Foundation, Inc., %%% with this program; if not, write to the Free Software Foundation, Inc.,
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. %%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
%%% %%%
%%%---------------------------------------------------------------------- %%%---------------------u-------------------------------------------------
-module(mod_vcard_ldap). -module(mod_vcard_ldap).
@ -723,7 +723,7 @@ find_xdata_el1([]) -> false;
find_xdata_el1([#xmlel{name = Name, attrs = Attrs, find_xdata_el1([#xmlel{name = Name, attrs = Attrs,
children = SubEls} children = SubEls}
| Els]) -> | Els]) ->
case xml:get_attr_s(<<"xmlns">>, Attrs) of case fxml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_XDATA -> ?NS_XDATA ->
#xmlel{name = Name, attrs = Attrs, children = SubEls}; #xmlel{name = Name, attrs = Attrs, children = SubEls};
_ -> find_xdata_el1(Els) _ -> find_xdata_el1(Els)

View File

@ -56,7 +56,7 @@ stop(Host) ->
update_presence(#xmlel{name = <<"presence">>, attrs = Attrs} = Packet, update_presence(#xmlel{name = <<"presence">>, attrs = Attrs} = Packet,
User, Host) -> User, Host) ->
case xml:get_attr_s(<<"type">>, Attrs) of case fxml:get_attr_s(<<"type">>, Attrs) of
<<>> -> presence_with_xupdate(Packet, User, Host); <<>> -> presence_with_xupdate(Packet, User, Host);
_ -> Packet _ -> Packet
end; end;
@ -64,7 +64,7 @@ update_presence(Packet, _User, _Host) -> Packet.
vcard_set(LUser, LServer, VCARD) -> vcard_set(LUser, LServer, VCARD) ->
US = {LUser, LServer}, US = {LUser, LServer},
case xml:get_path_s(VCARD, case fxml:get_path_s(VCARD,
[{elem, <<"PHOTO">>}, {elem, <<"BINVAL">>}, cdata]) [{elem, <<"PHOTO">>}, {elem, <<"BINVAL">>}, cdata])
of of
<<>> -> remove_xupdate(LUser, LServer); <<>> -> remove_xupdate(LUser, LServer);

View File

@ -824,7 +824,7 @@ set_item(Item) ->
{M, JID} = Item#pubsub_item.modification, {M, JID} = Item#pubsub_item.modification,
P = encode_jid(JID), P = encode_jid(JID),
Payload = Item#pubsub_item.payload, Payload = Item#pubsub_item.payload,
XML = ejabberd_odbc:escape(str:join([xml:element_to_binary(X) || X<-Payload], <<>>)), XML = ejabberd_odbc:escape(str:join([fxml:element_to_binary(X) || X<-Payload], <<>>)),
S = fun ({T1, T2, T3}) -> S = fun ({T1, T2, T3}) ->
str:join([jlib:i2l(T1, 6), jlib:i2l(T2, 6), jlib:i2l(T3, 6)], <<":">>) str:join([jlib:i2l(T1, 6), jlib:i2l(T2, 6), jlib:i2l(T3, 6)], <<":">>)
end, end,
@ -1041,7 +1041,7 @@ raw_to_item(Nidx, [ItemId, SJID, Creation, Modification, XML]) ->
[T1, T2, T3] = str:tokens(Str, <<":">>), [T1, T2, T3] = str:tokens(Str, <<":">>),
{jlib:l2i(T1), jlib:l2i(T2), jlib:l2i(T3)} {jlib:l2i(T1), jlib:l2i(T2), jlib:l2i(T3)}
end, end,
Payload = case xml_stream:parse_element(XML) of Payload = case fxml_stream:parse_element(XML) of
{error, _Reason} -> []; {error, _Reason} -> [];
El -> [El] El -> [El]
end, end,

View File

@ -123,7 +123,7 @@ convert_data(Host, "private", User, [Data]) ->
fun({_TagXMLNS, Raw}) -> fun({_TagXMLNS, Raw}) ->
case deserialize(Raw) of case deserialize(Raw) of
[El] -> [El] ->
XMLNS = xml:get_tag_attr_s(<<"xmlns">>, El), XMLNS = fxml:get_tag_attr_s(<<"xmlns">>, El),
[{XMLNS, El}]; [{XMLNS, El}];
_ -> _ ->
[] []
@ -301,7 +301,7 @@ convert_privacy_item({_, Item}) ->
el_to_offline_msg(LUser, LServer, #xmlel{attrs = Attrs} = El) -> el_to_offline_msg(LUser, LServer, #xmlel{attrs = Attrs} = El) ->
case jlib:datetime_string_to_timestamp( case jlib:datetime_string_to_timestamp(
xml:get_attr_s(<<"stamp">>, Attrs)) of fxml:get_attr_s(<<"stamp">>, Attrs)) of
{_, _, _} = TS -> {_, _, _} = TS ->
Attrs1 = lists:filter( Attrs1 = lists:filter(
fun(<<"stamp">>) -> false; fun(<<"stamp">>) -> false;
@ -309,8 +309,8 @@ el_to_offline_msg(LUser, LServer, #xmlel{attrs = Attrs} = El) ->
(_) -> true (_) -> true
end, Attrs), end, Attrs),
Packet = El#xmlel{attrs = Attrs1}, Packet = El#xmlel{attrs = Attrs1},
case {jid:from_string(xml:get_attr_s(<<"from">>, Attrs)), case {jid:from_string(fxml:get_attr_s(<<"from">>, Attrs)),
jid:from_string(xml:get_attr_s(<<"to">>, Attrs))} of jid:from_string(fxml:get_attr_s(<<"to">>, Attrs))} of
{#jid{} = From, #jid{} = To} -> {#jid{} = From, #jid{} = To} ->
[#offline_msg{ [#offline_msg{
us = {LUser, LServer}, us = {LUser, LServer},

View File

@ -126,7 +126,7 @@ get_options_xform(Lang, Options) ->
++ XFields}}. ++ XFields}}.
parse_options_xform(XFields) -> parse_options_xform(XFields) ->
case xml:remove_cdata(XFields) of case fxml:remove_cdata(XFields) of
[#xmlel{name = <<"x">>} = XEl] -> [#xmlel{name = <<"x">>} = XEl] ->
case jlib:parse_xdata_submit(XEl) of case jlib:parse_xdata_submit(XEl) of
XData when is_list(XData) -> XData when is_list(XData) ->

View File

@ -151,7 +151,7 @@ get_options_xform(Lang, Options) ->
++ XFields}}. ++ XFields}}.
parse_options_xform(XFields) -> parse_options_xform(XFields) ->
case xml:remove_cdata(XFields) of case fxml:remove_cdata(XFields) of
[#xmlel{name = <<"x">>} = XEl] -> [#xmlel{name = <<"x">>} = XEl] ->
case jlib:parse_xdata_submit(XEl) of case jlib:parse_xdata_submit(XEl) of
XData when is_list(XData) -> XData when is_list(XData) ->