From 3c88ab49f037ce610babea8261a57a39900d3176 Mon Sep 17 00:00:00 2001 From: Christophe Romain Date: Mon, 25 Aug 2008 13:11:25 +0000 Subject: [PATCH] Prevent case_clause error when ejabber_odbc:sql_query returns {error, Reason} SVN Revision: 1537 --- ChangeLog | 6 +++++ src/mod_privacy_odbc.erl | 50 +++++++++++++++++++++------------------- src/mod_vcard_odbc.erl | 2 +- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44ffdd97b..72695b9d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-08-25 Christophe Romain + + * src/mod_privacy_odbc.erl: Prevent case_clause error when + ejabber_odbc:sql_query returns {error, Reason} + * src/mod_vcard_odbc.erl: Likewise + 2008-08-25 Badlop * src/ejabberd_check.erl: Detect correctly MSSQL and ODBC diff --git a/src/mod_privacy_odbc.erl b/src/mod_privacy_odbc.erl index 263ec434d..11e3956eb 100644 --- a/src/mod_privacy_odbc.erl +++ b/src/mod_privacy_odbc.erl @@ -96,16 +96,14 @@ process_iq_get(_, From, _To, #iq{sub_el = SubEl}, process_lists_get(LUser, LServer, Active) -> Default = case catch sql_get_default_privacy_list(LUser, LServer) of - {'EXIT', _Reason} -> - none; {selected, ["name"], []} -> none; {selected, ["name"], [{DefName}]} -> - DefName + DefName; + _ -> + none end, case catch sql_get_privacy_list_names(LUser, LServer) of - {'EXIT', _Reason2} -> - {error, ?ERR_INTERNAL_SERVER_ERROR}; {selected, ["name"], []} -> {result, [{xmlelement, "query", [{"xmlns", ?NS_PRIVACY}], []}]}; {selected, ["name"], Names} -> @@ -132,19 +130,17 @@ process_lists_get(LUser, LServer, Active) -> end, {result, [{xmlelement, "query", [{"xmlns", ?NS_PRIVACY}], - ADItems}]} + ADItems}]}; + _ -> + {error, ?ERR_INTERNAL_SERVER_ERROR} end. process_list_get(LUser, LServer, {value, Name}) -> case catch sql_get_privacy_list_id(LUser, LServer, Name) of - {'EXIT', _Reason} -> - {error, ?ERR_INTERNAL_SERVER_ERROR}; {selected, ["id"], []} -> {error, ?ERR_ITEM_NOT_FOUND}; {selected, ["id"], [{ID}]} -> case catch sql_get_privacy_list_data_by_id(ID, LServer) of - {'EXIT', _Reason} -> - {error, ?ERR_INTERNAL_SERVER_ERROR}; {selected, ["t", "value", "action", "ord", "match_all", "match_iq", "match_message", "match_presence_in", "match_presence_out"], @@ -154,8 +150,12 @@ process_list_get(LUser, LServer, {value, Name}) -> {result, [{xmlelement, "query", [{"xmlns", ?NS_PRIVACY}], [{xmlelement, "list", - [{"name", Name}], LItems}]}]} - end + [{"name", Name}], LItems}]}]}; + _ -> + {error, ?ERR_INTERNAL_SERVER_ERROR} + end; + _ -> + {error, ?ERR_INTERNAL_SERVER_ERROR} end; process_list_get(_LUser, _LServer, false) -> @@ -294,6 +294,8 @@ process_default_set(LUser, LServer, false) -> case catch sql_unset_default_privacy_list(LUser, LServer) of {'EXIT', _Reason} -> {error, ?ERR_INTERNAL_SERVER_ERROR}; + {error, _Reason} -> + {error, ?ERR_INTERNAL_SERVER_ERROR}; _ -> {result, []} end. @@ -301,21 +303,21 @@ process_default_set(LUser, LServer, false) -> process_active_set(LUser, LServer, {value, Name}) -> case catch sql_get_privacy_list_id(LUser, LServer, Name) of - {'EXIT', _Reason} -> - {error, ?ERR_INTERNAL_SERVER_ERROR}; {selected, ["id"], []} -> {error, ?ERR_ITEM_NOT_FOUND}; {selected, ["id"], [{ID}]} -> case catch sql_get_privacy_list_data_by_id(ID, LServer) of - {'EXIT', _Reason} -> - {error, ?ERR_INTERNAL_SERVER_ERROR}; {selected, ["t", "value", "action", "ord", "match_all", "match_iq", "match_message", "match_presence_in", "match_presence_out"], RItems} -> Items = lists:map(fun raw_to_item/1, RItems), - {result, [], #userlist{name = Name, list = Items}} - end + {result, [], #userlist{name = Name, list = Items}}; + _ -> + {error, ?ERR_INTERNAL_SERVER_ERROR} + end; + _ -> + {error, ?ERR_INTERNAL_SERVER_ERROR} end; process_active_set(_LUser, _LServer, false) -> @@ -517,21 +519,21 @@ get_user_list(_, User, Server) -> LServer = jlib:nameprep(Server), case catch sql_get_default_privacy_list(LUser, LServer) of - {'EXIT', _Reason} -> - #userlist{}; {selected, ["name"], []} -> #userlist{}; {selected, ["name"], [{Default}]} -> case catch sql_get_privacy_list_data(LUser, LServer, Default) of - {'EXIT', _Reason} -> - #userlist{}; {selected, ["t", "value", "action", "ord", "match_all", "match_iq", "match_message", "match_presence_in", "match_presence_out"], RItems} -> Items = lists:map(fun raw_to_item/1, RItems), - #userlist{name = Default, list = Items} - end + #userlist{name = Default, list = Items}; + _ -> + #userlist{} + end; + _ -> + #userlist{} end. diff --git a/src/mod_vcard_odbc.erl b/src/mod_vcard_odbc.erl index 4a755829e..7c3d78dab 100644 --- a/src/mod_vcard_odbc.erl +++ b/src/mod_vcard_odbc.erl @@ -162,7 +162,7 @@ process_sm_iq(From, To, #iq{type = Type, sub_el = SubEl} = IQ) -> end; {selected, ["vcard"], []} -> IQ#iq{type = result, sub_el = []}; - {'EXIT', _Reason} -> + _ -> IQ#iq{type = error, sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]} end