24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-02 21:17:12 +02:00

*** empty log message ***

SVN Revision: 51
This commit is contained in:
Alexey Shchepin 2003-01-26 20:16:53 +00:00
parent b88ff5f323
commit aed24c637f
16 changed files with 240 additions and 107 deletions

2
TODO
View File

@ -5,6 +5,6 @@ admin interface
S2S timeouts S2S timeouts
rewrite S2S key validation rewrite S2S key validation
iq:browse(?) iq:browse(?)
SVR DNS records SRV DNS records
karma karma
SSL SSL

View File

@ -17,7 +17,7 @@
<H3 ALIGN=center>Alexey Shchepin<BR><A HREF="mailto:alexey@sevcom.net"><TT>mailto:alexey@sevcom.net</TT></A><BR><A HREF="xmpp:aleksey@jabber.ru"><TT>xmpp:aleksey@jabber.ru</TT></A></H3> <H3 ALIGN=center>Alexey Shchepin<BR><A HREF="mailto:alexey@sevcom.net"><TT>mailto:alexey@sevcom.net</TT></A><BR><A HREF="xmpp:aleksey@jabber.ru"><TT>xmpp:aleksey@jabber.ru</TT></A></H3>
<H3 ALIGN=center>January 23, 2003</H3> <DIV ALIGN=center><IMG SRC="logo.png"> <H3 ALIGN=center>January 26, 2003</H3> <DIV ALIGN=center><IMG SRC="logo.png">
</DIV><BR> </DIV><BR>
<BR> <BR>
@ -115,8 +115,8 @@ runned on them. Each element of list is a tuple with following elements:
<LI> <TT>ejabberd_s2s_in</TT>: serves incoming S2S connections; <LI> <TT>ejabberd_s2s_in</TT>: serves incoming S2S connections;
<LI> <TT>ejabberd_service</TT>: serves connections to Jabber services (i.e. <LI> <TT>ejabberd_service</TT>: serves connections to Jabber services
that use <TT>jabber:component:accept</TT> namespace). (i.&nbsp;e. that use <TT>jabber:component:accept</TT> namespace).
</UL>For example, following configuration defines that C2S connections listened on </UL>For example, following configuration defines that C2S connections listened on
port 5222, S2S on port 5269 and that service <TT>conference.jabber.org</TT> port 5222, S2S on port 5269 and that service <TT>conference.jabber.org</TT>
must be connected to port 8888 with password ``<TT>secret</TT>''.<BR> must be connected to port 8888 with password ``<TT>secret</TT>''.<BR>
@ -171,15 +171,13 @@ Example:
{access, configure, [{allow, admin}]}. {access, configure, [{allow, admin}]}.
{access, something, [{deny, badmans}, {access, something, [{deny, badmans},
{allow, all}]}. {allow, all}]}.
</PRE>TBD<BR> </PRE><!--TOC subsubsection Modules-->
<BR>
<!--TOC subsubsection Modules-->
<H4>3.1.4&nbsp;&nbsp; Modules</H4><!--SEC END --> <H4>3.1.4&nbsp;&nbsp; Modules</H4><!--SEC END -->
<A NAME="sec:configmodules"></A>Option <TT>modules</TT> defines list of modules that will be loaded after <A NAME="sec:configmodules"></A>Option <TT>modules</TT> defines list of modules that will be loaded after
<TT>ejabberd</TT> startup. Each list element is a tuple where first element is a <TT>ejabberd</TT> startup. Each list element is a tuple where first element is a
name of module and second is list of options to this module. Refer to name of module and second is list of options to this module. See
section&nbsp;<A HREF="#sec:modules">5</A> for detailed information on each module.<BR> section&nbsp;<A HREF="#sec:modules">5</A> for detailed information on each module.<BR>
<BR> <BR>
Example: Example:
@ -205,7 +203,7 @@ Example:
<TT>mod_configure</TT> loaded (see section&nbsp;<A HREF="#sec:modconfigure">5.4</A>). Also highly <TT>mod_configure</TT> loaded (see section&nbsp;<A HREF="#sec:modconfigure">5.4</A>). Also highly
recommended to load <TT>mod_disco</TT> (see section&nbsp;<A HREF="#sec:moddisco">5.5</A>), because recommended to load <TT>mod_disco</TT> (see section&nbsp;<A HREF="#sec:moddisco">5.5</A>), because
<TT>mod_configure</TT> highly integrates with it. Also recommended to use <TT>mod_configure</TT> highly integrates with it. Also recommended to use
disco-capable client.<BR> disco- and xdata-capable client.<BR>
<BR> <BR>
TBD<BR> TBD<BR>
<BR> <BR>

View File

@ -30,7 +30,7 @@
\author{Alexey Shchepin \\ \author{Alexey Shchepin \\
\ahrefurl{mailto:alexey@sevcom.net} \\ \ahrefurl{mailto:alexey@sevcom.net} \\
\ahrefurl{xmpp:aleksey@jabber.ru}} \ahrefurl{xmpp:aleksey@jabber.ru}}
\date{January 23, 2003} \date{January 26, 2003}
\begin{document} \begin{document}
\begin{titlepage} \begin{titlepage}
@ -78,7 +78,7 @@ To compile \ejabberd{}, you need following packages:
Currently no stable version released. Currently no stable version released.
Latest alpha version can be retrieved via CVS. Do following steps: Latest alpha version can be retrieved via CVS\@. Do following steps:
\begin{itemize} \begin{itemize}
\item \texttt{export CVSROOT=:pserver:cvs@www.jabber.ru:/var/spool/cvs} \item \texttt{export CVSROOT=:pserver:cvs@www.jabber.ru:/var/spool/cvs}
\item \texttt{cvs login} \item \texttt{cvs login}
@ -119,7 +119,7 @@ values.
\label{sec:confighostname} \label{sec:confighostname}
Option \texttt{hostname} defines name of \Jabber{} domain that \ejabberd{} Option \texttt{hostname} defines name of \Jabber{} domain that \ejabberd{}
serves. E.\,g. to use \texttt{jabber.org} domain add following line in config: serves. E.\,g.\ to use \texttt{jabber.org} domain add following line in config:
\begin{verbatim} \begin{verbatim}
{host, "jabber.org"}. {host, "jabber.org"}.
\end{verbatim} \end{verbatim}
@ -144,8 +144,8 @@ Currently three modules implemented:
\begin{itemize} \begin{itemize}
\item \texttt{ejabberd\_c2s}: serves C2S connections; \item \texttt{ejabberd\_c2s}: serves C2S connections;
\item \texttt{ejabberd\_s2s\_in}: serves incoming S2S connections; \item \texttt{ejabberd\_s2s\_in}: serves incoming S2S connections;
\item \texttt{ejabberd\_service}: serves connections to \Jabber{} services (i.e. \item \texttt{ejabberd\_service}: serves connections to \Jabber{} services
that use \texttt{jabber:component:accept} namespace). (i.\,e.\ that use \texttt{jabber:component:accept} namespace).
\end{itemize} \end{itemize}
For example, following configuration defines that C2S connections listened on For example, following configuration defines that C2S connections listened on
@ -218,7 +218,7 @@ Example:
Option \texttt{modules} defines list of modules that will be loaded after Option \texttt{modules} defines list of modules that will be loaded after
\ejabberd{} startup. Each list element is a tuple where first element is a \ejabberd{} startup. Each list element is a tuple where first element is a
name of module and second is list of options to this module. Refer to name of module and second is list of options to this module. See
section~\ref{sec:modules} for detailed information on each module. section~\ref{sec:modules} for detailed information on each module.
Example: Example:
@ -246,7 +246,7 @@ To use facility of online reconfiguration of \ejabberd{} needed to have
\modconfigure{} loaded (see section~\ref{sec:modconfigure}). Also highly \modconfigure{} loaded (see section~\ref{sec:modconfigure}). Also highly
recommended to load \moddisco{} (see section~\ref{sec:moddisco}), because recommended to load \moddisco{} (see section~\ref{sec:moddisco}), because
\modconfigure{} highly integrates with it. Also recommended to use \modconfigure{} highly integrates with it. Also recommended to use
disco-capable client. disco- and xdata-capable client.
TBD TBD
@ -258,12 +258,12 @@ TBD
\label{sec:howitworks} \label{sec:howitworks}
\Jabber{} domain is served by one or more \ejabberd{} nodes. This nodes can be \Jabber{} domain is served by one or more \ejabberd{} nodes. This nodes can be
runned on different computers that can be connected via network. They all must runned on different machines that can be connected via network. They all must
have access to connect to port 4369 of all another nodes, and must have same have access to connect to port 4369 of all another nodes, and must have same
magic cookie (see Erlang/OTP documentation, in short file magic cookie (see Erlang/OTP documentation, in short file
\texttt{\~ejabberd/.erlang.cookie} must be the same on all nodes). This is \texttt{\~ejabberd/.erlang.cookie} must be the same on all nodes). This is
needed because all nodes exchange information about connected users, S2S needed because all nodes exchange information about connected users, S2S
connection ,registered services, etc... connection, registered services, etc\ldots
Each \ejabberd{} node run following modules: Each \ejabberd{} node run following modules:
\begin{itemize} \begin{itemize}
@ -322,7 +322,7 @@ Following options used by many modules, so they described in separate section.
\subsubsection{Option \texttt{iqdisc}} \subsubsection{Option \texttt{iqdisc}}
Many modules define handlers for processing IQ queries of different namespaces Many modules define handlers for processing IQ queries of different namespaces
to this server or to user (e.\,g. to \texttt{myjabber.org} or to to this server or to user (e.\,g.\ to \texttt{myjabber.org} or to
\texttt{user@myjabber.org}). This option defines processing discipline of this \texttt{user@myjabber.org}). This option defines processing discipline of this
queries. Possible values are: queries. Possible values are:
\begin{description} \begin{description}

View File

@ -19,6 +19,9 @@ start() ->
init() -> init() ->
register(ejabberd, self()), register(ejabberd, self()),
% Profiling
%eprof:start(),
%eprof:profile([self()]),
%erlang:system_flag(fullsweep_after, 0), %erlang:system_flag(fullsweep_after, 0),
error_logger:logfile({open, ?ERROR_LOG_PATH}), error_logger:logfile({open, ?ERROR_LOG_PATH}),
randoms:start(), randoms:start(),

View File

@ -8,8 +8,8 @@
-define(VERSION, "0.0.1-alpha"). -define(VERSION, "0.0.1-alpha").
%-define(ejabberd_debug, true). -define(ejabberd_debug, true).
%-define(DBGFSM, true). -define(DBGFSM, true).
-ifdef(ejabberd_debug). -ifdef(ejabberd_debug).
-define(DEBUG(Format, Args), io:format("D(~p:~p:~p) : "++Format++"~n", -define(DEBUG(Format, Args), io:format("D(~p:~p:~p) : "++Format++"~n",
@ -25,6 +25,7 @@
%-define(MYNAME,"e.localhost"). %-define(MYNAME,"e.localhost").
-define(MYNAME, ejabberd_config:get_global_option(host)). -define(MYNAME, ejabberd_config:get_global_option(host)).
-define(S2STIMEOUT, 1200000).
-define(MSGS_DIR, "msgs"). -define(MSGS_DIR, "msgs").
-define(CONFIG_PATH, "ejabberd.cfg"). -define(CONFIG_PATH, "ejabberd.cfg").

View File

@ -23,7 +23,8 @@
try_register/2, try_register/2,
dirty_get_registered_users/0, dirty_get_registered_users/0,
get_password_s/1, get_password_s/1,
is_user_exists/1]). is_user_exists/1,
remove_user/1]).
%% gen_server callbacks %% gen_server callbacks
-export([init/1, -export([init/1,
@ -198,3 +199,10 @@ is_user_exists(User) ->
_ -> _ ->
false false
end. end.
remove_user(User) ->
LUser = jlib:tolower(User),
F = fun() ->
mnesia:delete({passwd, LUser})
end,
mnesia:transaction(F).

View File

@ -106,18 +106,6 @@ have_connection(FromTo) ->
false false
end. end.
%get_key(FromTo) ->
% F = fun() ->
% [E] = mnesia:read({s2s, FromTo}),
% E
% end,
% case mnesia:transaction(F) of
% {atomic, E} ->
% E#s2s.key;
% _ ->
% ""
% end.
get_key(FromTo) -> get_key(FromTo) ->
case catch mnesia:dirty_read(s2s, FromTo) of case catch mnesia:dirty_read(s2s, FromTo) of
[E] -> [E] ->
@ -159,24 +147,7 @@ do_route(From, To, Packet) ->
{User, Server, Resource} = To, {User, Server, Resource} = To,
FromTo = {MyServer, Server}, FromTo = {MyServer, Server},
Key = randoms:get_string(), Key = randoms:get_string(),
F = fun() -> case find_connection(FromTo, Key) of
case mnesia:read({local_s2s, FromTo}) of
[] ->
case mnesia:read({s2s, FromTo}) of
[Er] ->
{remote, Er#s2s.node};
[] ->
% TODO
mnesia:write(#s2s{fromto = FromTo,
node = node(),
key = Key}),
new
end;
[El] ->
{local, El#local_s2s.pid}
end
end,
case mnesia:transaction(F) of
{atomic, {local, Pid}} -> {atomic, {local, Pid}} ->
?DEBUG("sending to process ~p~n", [Pid]), ?DEBUG("sending to process ~p~n", [Pid]),
% TODO % TODO
@ -211,6 +182,38 @@ do_route(From, To, Packet) ->
false false
end. end.
find_connection(FromTo, Key) ->
F = fun() ->
case mnesia:read({local_s2s, FromTo}) of
[] ->
case mnesia:read({s2s, FromTo}) of
[Er] ->
{remote, Er#s2s.node};
[] ->
mnesia:write(#s2s{fromto = FromTo,
node = node(),
key = Key}),
new
end;
[El] ->
{local, El#local_s2s.pid}
end
end,
case catch mnesia:dirty_read({local_s2s, FromTo}) of
{'EXIT', Reason} ->
{aborted, Reason};
[] ->
case catch mnesia:dirty_read({s2s, FromTo}) of
[Er] ->
{atomic, {remote, Er#s2s.node}};
[] ->
mnesia:transaction(F)
end;
[El] ->
{atomic, {local, El#local_s2s.pid}}
end.
send_element(Pid, El) -> send_element(Pid, El) ->
Pid ! {send_element, El}. Pid ! {send_element, El}.

View File

@ -250,12 +250,15 @@ stream_established({xmlstreamelement, El}, StateData) ->
error error
end end
end, end,
{next_state, stream_established, StateData}; {next_state, stream_established, StateData, ?S2STIMEOUT};
stream_established({xmlstreamend, Name}, StateData) -> stream_established({xmlstreamend, Name}, StateData) ->
% TODO % TODO
{stop, normal, StateData}; {stop, normal, StateData};
stream_established(timeout, StateData) ->
{stop, normal, StateData};
stream_established(closed, StateData) -> stream_established(closed, StateData) ->
% TODO % TODO
{stop, normal, StateData}. {stop, normal, StateData}.

View File

@ -175,7 +175,7 @@ wait_for_validation({xmlstreamelement, El}, StateData) ->
case Type of case Type of
"valid" -> "valid" ->
send_queue(StateData#state.socket, StateData#state.queue), send_queue(StateData#state.socket, StateData#state.queue),
{next_state, stream_established, StateData}; {next_state, stream_established, StateData, ?S2STIMEOUT};
_ -> _ ->
% TODO: bounce packets % TODO: bounce packets
{stop, normal, StateData} {stop, normal, StateData}
@ -212,6 +212,7 @@ wait_for_validation(closed, StateData) ->
stream_established({xmlstreamelement, El}, StateData) -> stream_established({xmlstreamelement, El}, StateData) ->
io:format("s2s out~n"),
case is_verify_res(El) of case is_verify_res(El) of
{verify, VTo, VFrom, VId, VType} -> {verify, VTo, VFrom, VId, VType} ->
case StateData#state.verify of case StateData#state.verify of
@ -228,36 +229,36 @@ stream_established({xmlstreamelement, El}, StateData) ->
_ -> _ ->
ok ok
end, end,
{xmlelement, Name, Attrs, Els} = El, %{xmlelement, Name, Attrs, Els} = El,
% TODO %From = xml:get_attr_s("from", Attrs),
From = xml:get_attr_s("from", Attrs), %FromJID1 = jlib:string_to_jid(From),
FromJID1 = jlib:string_to_jid(From), %FromJID = case FromJID1 of
FromJID = case FromJID1 of % {Node, Server, Resource} ->
{Node, Server, Resource} -> % if Server == StateData#state.server -> FromJID1;
if Server == StateData#state.server -> FromJID1; % true -> error
true -> error % end;
end; % _ -> error
_ -> error % end,
end, %To = xml:get_attr_s("to", Attrs),
To = xml:get_attr_s("to", Attrs), %ToJID = case To of
ToJID = case To of % "" -> error;
"" -> error; % _ -> jlib:string_to_jid(To)
_ -> jlib:string_to_jid(To) % end,
end, %if ((Name == "iq") or (Name == "message") or (Name == "presence")) and
if ((Name == "iq") or (Name == "message") or (Name == "presence")) and % (ToJID /= error) and (FromJID /= error) ->
(ToJID /= error) and (FromJID /= error) -> % ejabberd_router:route(FromJID, ToJID, El);
ejabberd_router:route(FromJID, ToJID, El); % true ->
true -> % error
error %end,
end, {next_state, stream_established, StateData, ?S2STIMEOUT};
{next_state, stream_established, StateData};
stream_established({xmlstreamend, Name}, StateData) -> stream_established({xmlstreamend, Name}, StateData) ->
% TODO {stop, normal, StateData};
stream_established(timeout, StateData) ->
{stop, normal, StateData}; {stop, normal, StateData};
stream_established(closed, StateData) -> stream_established(closed, StateData) ->
% TODO
{stop, normal, StateData}. {stop, normal, StateData}.

View File

@ -211,13 +211,32 @@ is_nodename1([]) ->
% TODO: UNICODE support % TODO: UNICODE support
tolower_c(C) when C >= $A, C =< $Z -> %tolower_c(C) when C >= $A, C =< $Z ->
C + 32; % C + 32;
tolower_c(C) -> %tolower_c(C) ->
C. % C.
tolower(S) -> -define(LOWER(Char),
lists:map(fun tolower_c/1, S). if
Char >= $A, Char =< $Z ->
Char + 32;
true ->
Char
end).
%tolower(S) ->
% lists:map(fun tolower_c/1, S).
%tolower(S) ->
% [?LOWER(Char) || Char <- S].
% Not tail-recursive but it seems works faster than variants above
tolower([C | Cs]) when C >= $A, C =< $Z ->
[C + 32 | tolower(Cs)];
tolower([C | Cs]) ->
[C | tolower(Cs)];
tolower([]) ->
[].
jid_tolower({U, S, R}) -> jid_tolower({U, S, R}) ->

View File

@ -202,6 +202,25 @@ get_form(["config", "acls"], Lang) ->
} }
]}; ]};
get_form(["config", "remusers"], Lang) ->
{result, [{xmlelement, "title", [],
[{xmlcdata,
translate:translate(
Lang, "Remove Users")}]},
{xmlelement, "instructions", [],
[{xmlcdata,
translate:translate(
Lang, "Choose users to remove")}]}] ++
case catch ejabberd_auth:dirty_get_registered_users() of
{'EXIT', Reason} ->
[];
Users ->
lists:map(fun(U) ->
?XFIELD("boolean", U, U, "0")
end, lists:sort(Users))
end
};
get_form(_, Lang) -> get_form(_, Lang) ->
{error, "503", "Service Unavailable"}. {error, "503", "Service Unavailable"}.
@ -254,6 +273,21 @@ set_form(["config", "hostname"], Lang, XData) ->
{error, "406", "Not Acceptable"} {error, "406", "Not Acceptable"}
end; end;
set_form(["config", "remusers"], Lang, XData) ->
lists:foreach(
fun({Var, Vals}) ->
case Vals of
["1"] ->
catch ejabberd_auth:remove_user(Var),
catch mod_roster:remove_user(Var),
catch mod_offline:remove_user(Var),
catch mod_vcard:remove_user(Var);
_ ->
ok
end
end, XData),
{result, []};
set_form(_, Lang, XData) -> set_form(_, Lang, XData) ->
{error, "503", "Service Unavailable"}. {error, "503", "Service Unavailable"}.

View File

@ -160,7 +160,8 @@ get_local_items(["config"], Server, Lang) ->
[?NODE("Host Name", "config/hostname"), [?NODE("Host Name", "config/hostname"),
?NODE("ACLs", "config/acls"), ?NODE("ACLs", "config/acls"),
?NODE("Access Rules", "config/access"), ?NODE("Access Rules", "config/access"),
?NODE("Loaded Modules", "config/modules") ?NODE("Loaded Modules", "config/modules"),
?NODE("Remove Users", "config/remusers")
]}; ]};
get_local_items(["config", _], Server, Lang) -> get_local_items(["config", _], Server, Lang) ->

View File

@ -13,7 +13,8 @@
-export([start/1, -export([start/1,
store_packet/3, store_packet/3,
resend_offline_messages/1]). resend_offline_messages/1,
remove_user/1]).
-include("namespaces.hrl"). -include("namespaces.hrl").
@ -115,3 +116,10 @@ resend_offline_messages(User) ->
_ -> _ ->
ok ok
end. end.
remove_user(User) ->
LUser = jlib:tolower(User),
F = fun() ->
mnesia:delete({offline_msg, LUser})
end,
mnesia:transaction(F).

View File

@ -17,7 +17,8 @@
process_local_iq/3, process_local_iq/3,
get_subscription_lists/1, get_subscription_lists/1,
in_subscription/3, in_subscription/3,
out_subscription/3]). out_subscription/3,
remove_user/1]).
-include_lib("mnemosyne/include/mnemosyne.hrl"). -include_lib("mnemosyne/include/mnemosyne.hrl").
-include("ejabberd.hrl"). -include("ejabberd.hrl").
@ -459,3 +460,13 @@ out_subscription(User, JID, Type) ->
false false
end. end.
remove_user(User) ->
LUser = jlib:tolower(User),
F = fun() ->
lists:foreach(fun(R) ->
mnesia:delete_object(R)
end,
mnesia:index_read(roster, LUser, #roster.user))
end,
mnesia:transaction(F).

View File

@ -15,7 +15,8 @@
-export([start/1, init/1, -export([start/1, init/1,
process_local_iq/3, process_local_iq/3,
process_sm_iq/3, process_sm_iq/3,
reindex_vcards/0]). reindex_vcards/0,
remove_user/1]).
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-include("namespaces.hrl"). -include("namespaces.hrl").
@ -478,3 +479,16 @@ reindex_vcards() ->
mnesia:transaction(F). mnesia:transaction(F).
remove_user(User) ->
LUser = jlib:tolower(User),
F = fun() ->
mnesia:delete({vcard, LUser}),
lists:foreach(fun(R) ->
mnesia:delete_object(R)
end,
mnesia:index_read(vcard_search,
LUser,
#vcard_search.luser))
end,
mnesia:transaction(F).

View File

@ -10,7 +10,9 @@
-author('alexey@sevcom.net'). -author('alexey@sevcom.net').
-vsn('$Revision$ '). -vsn('$Revision$ ').
-export([element_to_string/1, crypt/1, remove_cdata/1, -export([element_to_string/1,
crypt/1,
remove_cdata/1,
get_cdata/1, get_tag_cdata/1, get_cdata/1, get_tag_cdata/1,
get_attr/2, get_attr_s/2, get_attr/2, get_attr_s/2,
get_tag_attr/2, get_tag_attr_s/2, get_tag_attr/2, get_tag_attr_s/2,
@ -38,23 +40,50 @@ attrs_to_string(Attrs) ->
attr_to_string({Name, Value}) -> attr_to_string({Name, Value}) ->
" " ++ crypt(Name) ++ "='" ++ crypt(Value) ++ "'". " " ++ crypt(Name) ++ "='" ++ crypt(Value) ++ "'".
crypt(S) -> %crypt(S) ->
lists:reverse(crypt(S, "")). % lists:reverse(crypt(S, "")).
%
%crypt([$& | S], R) ->
% crypt(S, [$;, $p, $m, $a, $& | R]);
%crypt([$< | S], R) ->
% crypt(S, [$;, $t, $l, $& | R]);
%crypt([$> | S], R) ->
% crypt(S, [$;, $t, $g, $& | R]);
%crypt([$" | S], R) ->
% crypt(S, [$;, $t, $o, $u, $q, $& | R]);
%crypt([$' | S], R) ->
% crypt(S, [$;, $s, $o, $p, $a, $& | R]);
%crypt([C | S], R) ->
% crypt(S, [C | R]);
%crypt([], R) ->
% R.
%crypt1(S) ->
% lists:flatten([case C of
% $& -> "&amp;";
% $< -> "&lt;";
% $> -> "&gt;";
% $" -> "&quot;";
% $' -> "&apos;";
% _ -> C
% end || C <- S]).
% Not tail-recursive but it seems works faster than variants above
crypt([$& | S]) ->
[$&, $a, $m, $p, $; | crypt(S)];
crypt([$< | S]) ->
[$&, $l, $t, $; | crypt(S)];
crypt([$> | S]) ->
[$&, $g, $t, $; | crypt(S)];
crypt([$" | S]) ->
[$&, $q, $u, $o, $t, $; | crypt(S)];
crypt([$' | S]) ->
[$&, $a, $p, $o, $s, $; | crypt(S)];
crypt([C | S]) ->
[C | crypt(S)];
crypt([]) ->
[].
crypt([$& | S], R) ->
crypt(S, [$;, $p, $m, $a, $& | R]);
crypt([$< | S], R) ->
crypt(S, [$;, $t, $l, $& | R]);
crypt([$> | S], R) ->
crypt(S, [$;, $t, $g, $& | R]);
crypt([$" | S], R) ->
crypt(S, [$;, $t, $o, $u, $q, $& | R]);
crypt([$' | S], R) ->
crypt(S, [$;, $s, $o, $p, $a, $& | R]);
crypt([C | S], R) ->
crypt(S, [C | R]);
crypt([], R) ->
R.
remove_cdata_p({xmlelement, Name, Attrs, Els}) -> true; remove_cdata_p({xmlelement, Name, Attrs, Els}) -> true;