diff options
author | Badlop <badlop@process-one.net> | 2009-10-20 15:28:48 +0000 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2009-10-20 15:28:48 +0000 |
commit | 04545f2668a09c5a235007d663a2de0897dd9d18 (patch) | |
tree | be39dbe996ef704c8a121263e107093f710faa90 /src/xml.erl | |
parent | add release_notes_2.0.1 (diff) | |
parent | does not use slash as default separator in nodename (EJAB-667) (diff) |
Create branch for ejabberd 2.1.x release line.
SVN Revision: 2688
Diffstat (limited to 'src/xml.erl')
-rw-r--r-- | src/xml.erl | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/xml.erl b/src/xml.erl index 4fb998c58..aeb085ea5 100644 --- a/src/xml.erl +++ b/src/xml.erl @@ -5,7 +5,7 @@ %%% Created : 20 Nov 2002 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2008 Process-one +%%% ejabberd, Copyright (C) 2002-2009 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -16,7 +16,7 @@ %%% but WITHOUT ANY WARRANTY; without even the implied warranty of %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %%% General Public License for more details. -%%% +%%% %%% You should have received a copy of the GNU General Public License %%% along with this program; if not, write to the Free Software %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA @@ -34,6 +34,7 @@ get_attr/2, get_attr_s/2, get_tag_attr/2, get_tag_attr_s/2, get_subtag/2, get_subtag_cdata/2, + append_subtags/2, get_path_s/2, replace_tag_attr/3]). @@ -47,18 +48,26 @@ -endif. element_to_string(El) -> + case catch element_to_string_nocatch(El) of + {'EXIT', Reason} -> + erlang:error({badxml, El, Reason}); + Result -> + Result + end. + +element_to_string_nocatch(El) -> case El of {xmlelement, Name, Attrs, Els} -> if Els /= [] -> [$<, Name, attrs_to_list(Attrs), $>, - [element_to_string(E) || E <- Els], + [element_to_string_nocatch(E) || E <- Els], $<, $/, Name, $>]; true -> [$<, Name, attrs_to_list(Attrs), $/, $>] end; %% We do not crypt CDATA binary, but we enclose it in XML CDATA - {xmlcdata, CData} when binary(CData) -> + {xmlcdata, CData} when is_binary(CData) -> ?ESCAPE_BINARY(CData); %% We crypt list and possibly binaries if full XML usage is %% disabled unsupported (implies a conversion to list). @@ -70,7 +79,7 @@ attrs_to_list(Attrs) -> [attr_to_list(A) || A <- Attrs]. attr_to_list({Name, Value}) -> - [$\s, crypt(Name), $=, $', crypt(Value), $']. + [$\s, Name, $=, $', crypt(Value), $']. crypt(S) when is_list(S) -> [case C of @@ -211,6 +220,9 @@ get_subtag_cdata(Tag, Name) -> get_tag_cdata(Subtag) end. +append_subtags({xmlelement, Name, Attrs, SubTags1}, SubTags2) -> + {xmlelement, Name, Attrs, SubTags1 ++ SubTags2}. + get_path_s(El, []) -> El; get_path_s(El, [{elem, Name} | Path]) -> |