25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

Add support for #xmlel to parse_xdata_submit/1 and friends. This fixes

the user search in mod_vcard.

SVN Revision: 1466
This commit is contained in:
Jean-Sébastien Pédron 2008-07-21 15:54:47 +00:00
parent 4a1e45070e
commit a8ab6c1568
2 changed files with 22 additions and 0 deletions

View File

@ -9,6 +9,9 @@
* src/mod_vcard.erl: One call to jlib:jid_to_string/1 was remaining.
* src/jlib.erl: Add support for #xmlel to parse_xdata_submit/1 and
friends. This fixes the user search in mod_vcard.
2008-07-17 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
Merge revisions from 1444 to revision 1457 from trunk.

View File

@ -448,6 +448,13 @@ iq_to_xml(#iq{id = ID, type = Type, sub_el = SubEl}) ->
end.
parse_xdata_submit({xmlel, _, _, _, Attrs, Els}) ->
case exmpp_xml:get_attribute_from_list(Attrs, 'type') of
"submit" ->
lists:reverse(parse_xdata_fields(Els, []));
_ ->
invalid
end;
parse_xdata_submit(El) ->
{xmlelement, _Name, Attrs, Els} = El,
case xml:get_attr_s("type", Attrs) of
@ -459,6 +466,15 @@ parse_xdata_submit(El) ->
parse_xdata_fields([], Res) ->
Res;
parse_xdata_fields([{xmlel, _, _, 'field', Attrs, SubEls} | Els],
Res) ->
case exmpp_xml:get_attribute_from_list(Attrs, 'var') of
"" ->
parse_xdata_fields(Els, Res);
Var ->
Field = {Var, lists:reverse(parse_xdata_values(SubEls, []))},
parse_xdata_fields(Els, [Field | Res])
end;
parse_xdata_fields([{xmlelement, Name, Attrs, SubEls} | Els], Res) ->
case Name of
"field" ->
@ -478,6 +494,9 @@ parse_xdata_fields([_ | Els], Res) ->
parse_xdata_values([], Res) ->
Res;
parse_xdata_values([{xmlel, _, _, 'value', _, SubEls} | Els], Res) ->
Val = exmpp_xml:get_cdata_from_list_as_list(SubEls),
parse_xdata_values(Els, [Val | Res]);
parse_xdata_values([{xmlelement, Name, _Attrs, SubEls} | Els], Res) ->
case Name of
"value" ->