From a8ab6c1568abe882dd529fa60ce6afb146a12e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Mon, 21 Jul 2008 15:54:47 +0000 Subject: [PATCH] Add support for #xmlel to parse_xdata_submit/1 and friends. This fixes the user search in mod_vcard. SVN Revision: 1466 --- ChangeLog | 3 +++ src/jlib.erl | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index cc53893a8..e18a404d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 Merge revisions from 1444 to revision 1457 from trunk. diff --git a/src/jlib.erl b/src/jlib.erl index b926c15fb..698e704e4 100644 --- a/src/jlib.erl +++ b/src/jlib.erl @@ -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" ->