summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMickaël Rémond <mickael.remond@process-one.net>2007-07-30 08:32:47 +0000
committerMickaël Rémond <mickael.remond@process-one.net>2007-07-30 08:32:47 +0000
commitb8cd5c3f0e5256f31a43221b7584c6582d4c3af9 (patch)
tree3021a026d83892a42b52a505fb0d7671074c9076
parent* src/mod_roster_odbc.erl: Better error management when bad JID in roster tab... (diff)
* src/xml.erl: Do not crypt binary CData, but enclose the value in
XML CDATA "tag". * src/xml.erl: Code clean-up: removed old code in comments. SVN Revision: 836
Diffstat (limited to '')
-rw-r--r--ChangeLog7
-rw-r--r--src/xml.erl73
2 files changed, 14 insertions, 66 deletions
diff --git a/ChangeLog b/ChangeLog
index 2a67d0d4..0bb42bff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-07-30 Mickael Remond <mickael.remond@process-one.net>
+
+ * src/xml.erl: Do not crypt binary CData, but enclose the value in
+ XML CDATA "tag".
+
+ * src/xml.erl: Code clean-up: removed old code in comments.
+
2007-07-28 Mickael Remond <mickael.remond@process-one.net>
* src/mod_roster_odbc.erl: Better error management when bad JID in
diff --git a/src/xml.erl b/src/xml.erl
index 00223966..4fae4827 100644
--- a/src/xml.erl
+++ b/src/xml.erl
@@ -20,50 +20,6 @@
get_path_s/2,
replace_tag_attr/3]).
-%element_to_string(El) ->
-% case El of
-% {xmlelement, Name, Attrs, Els} ->
-% if length(Els) > 0 ->
-% "<" ++ Name ++ attrs_to_string(Attrs) ++ ">" ++
-% lists:append(
-% lists:map(fun(E) -> element_to_string(E) end, Els))
-% ++ "</" ++ Name ++ ">";
-% true ->
-% "<" ++ Name ++ attrs_to_string(Attrs) ++ "/>"
-% end;
-% {xmlcdata, CData} -> crypt(CData)
-% end.
-%
-%
-%attrs_to_string(Attrs) ->
-% lists:append(lists:map(fun(A) -> attr_to_string(A) end, Attrs)).
-%
-%attr_to_string({Name, Value}) ->
-% " " ++ crypt(Name) ++ "='" ++ crypt(Value) ++ "'".
-
-
-%element_to_string2(El) ->
-% lists:flatten(element_to_string21(El)).
-%
-%element_to_string21(El) ->
-% case El of
-% {xmlelement, Name, Attrs, Els} ->
-% if length(Els) > 0 ->
-% [[$< | Name], attrs_to_list(Attrs), ">",
-% lists:map(fun(E) -> element_to_string21(E) end, Els),
-% "</", Name, ">"];
-% true ->
-% ["<", Name, attrs_to_list(Attrs), "/>"]
-% end;
-% {xmlcdata, CData} -> crypt(CData)
-% end.
-%
-%attrs_to_list(Attrs) ->
-% lists:map(fun(A) -> attr_to_list(A) end, Attrs).
-%
-%attr_to_list({Name, Value}) ->
-% [" ", crypt(Name), "='", crypt(Value), "'"].
-
element_to_string(El) ->
case El of
{xmlelement, Name, Attrs, Els} ->
@@ -75,8 +31,13 @@ element_to_string(El) ->
true ->
[$<, Name, attrs_to_list(Attrs), $/, $>]
end;
- {xmlcdata, CData} ->
- crypt(CData)
+ {xmlcdata, CData} when list(CData) ->
+ crypt(CData);
+ %% We do not crypt CDATA binary, but we enclose it in XML CDATA
+ {xmlcdata, CData} when binary(CData) ->
+ CDATA1 = <<"<![CDATA[">>,
+ CDATA2 = <<"]]>">>,
+ concat_binary([CDATA1, CData, CDATA2])
end.
attrs_to_list(Attrs) ->
@@ -85,26 +46,6 @@ attrs_to_list(Attrs) ->
attr_to_list({Name, Value}) ->
[$\s, crypt(Name), $=, $', crypt(Value), $'].
-
-
-%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.
-
crypt(S) when is_list(S) ->
[case C of
$& -> "&amp;";