From 8664881c8ffdecf95c84107aa3c11d144d78e936 Mon Sep 17 00:00:00 2001 From: Alexey Shchepin Date: Thu, 20 Feb 2003 17:12:03 +0000 Subject: [PATCH] * src/mod_roster.erl: Fixed bug with handling of roster set stanzas that contains CDATA * src/mod_irc/mod_irc_connection.erl (handle_info/3): Fixed parsing of string that have "\n" line separators (not "\r\n") SVN Revision: 79 --- ChangeLog | 8 ++++++++ src/mod_irc/mod_irc_connection.erl | 2 +- src/mod_roster.erl | 17 ++++++++--------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3929108f2..3debdf201 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-02-20 Alexey Shchepin + + * src/mod_roster.erl: Fixed bug with handling of roster set + stanzas that contains CDATA + + * src/mod_irc/mod_irc_connection.erl (handle_info/3): Fixed + parsing of string that have "\n" line separators (not "\r\n") + 2003-02-18 Alexey Shchepin * src/mod_irc/: Added support for private chats, nicks changes and diff --git a/src/mod_irc/mod_irc_connection.erl b/src/mod_irc/mod_irc_connection.erl index 391d2ccde..4b1ff0090 100644 --- a/src/mod_irc/mod_irc_connection.erl +++ b/src/mod_irc/mod_irc_connection.erl @@ -365,7 +365,7 @@ handle_info({send_element, El}, StateName, StateData) -> end; handle_info({tcp, Socket, Data}, StateName, StateData) -> Buf = StateData#state.inbuf ++ binary_to_list(Data), - {ok, Strings} = regexp:split(Buf, "\r\n"), + {ok, Strings} = regexp:split([C || C <- Buf, C /= $\r], "\n"), io:format("strings=~p~n", [Strings]), NewBuf = process_lines(Strings), {next_state, StateName, StateData#state{inbuf = NewBuf}}; diff --git a/src/mod_roster.erl b/src/mod_roster.erl index ca0801238..dda0e988a 100644 --- a/src/mod_roster.erl +++ b/src/mod_roster.erl @@ -125,9 +125,7 @@ process_iq_set(From, To, {iq, ID, Type, XMLNS, SubEl}) -> lists:foreach(fun(El) -> process_item_set(User, From, To, El) end, Els), {iq, ID, result, XMLNS, []}. -process_item_set(User, From, To, XItem) -> - {xmlelement, Name, Attrs, Els} = XItem, - % TODO: load existing item +process_item_set(User, From, To, {xmlelement, Name, Attrs, Els} = XItem) -> JID = jlib:string_to_jid(xml:get_attr_s("jid", Attrs)), LUser = jlib:tolower(User), case JID of @@ -199,7 +197,9 @@ process_item_set(User, From, To, XItem) -> ?DEBUG("ROSTER: roster item set error: ~p~n", [E]), ok end - end. + end; +process_item_set(User, From, To, _) -> + ok. process_item_attrs(Item, [{Attr, Val} | Attrs]) -> case Attr of @@ -231,7 +231,6 @@ process_item_attrs(Item, []) -> Item. -% {user, jid, name, subscription, groups, xattrs, xs} process_item_els(Item, [{xmlelement, Name, Attrs, SEls} | Els]) -> case Name of "group" -> @@ -480,8 +479,7 @@ set_items(User, SubEl) -> end, mnesia:transaction(F). -process_item_set_t(User, XItem) -> - {xmlelement, Name, Attrs, Els} = XItem, +process_item_set_t(User, {xmlelement, Name, Attrs, Els} = XItem) -> JID = jlib:string_to_jid(xml:get_attr_s("jid", Attrs)), LUser = jlib:tolower(User), case JID of @@ -501,8 +499,9 @@ process_item_set_t(User, XItem) -> _ -> mnesia:write(Item2) end - end. - + end; +process_item_set_t(User, _) -> + ok. process_item_attrs_ws(Item, [{Attr, Val} | Attrs]) -> case Attr of