25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

* src/xml.erl: Only wrap xmldata nodes in xml cdata "tag" if bigger than 50 bytes. Shorter xmlcdata nodes will be escaped.

SVN Revision: 842
This commit is contained in:
Mickaël Rémond 2007-07-30 13:13:59 +00:00
parent 15eee1c604
commit af33f13371
2 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,8 @@
2007-07-30 Mickael Remond <mickael.remond@process-one.net>
* src/xml.erl: Only wrap xmldata nodes in xml cdata "tag" if
bigger than 50 bytes. Shorter xmlcdata nodes will be escaped.
* src/tls/tls_drv.c: Sends the entire certificate chain (EJAB-209).
* src/acl.erl: Remove compilation warnings (EJAB-290).

View File

@ -20,6 +20,9 @@
get_path_s/2,
replace_tag_attr/3]).
%% XML CDATA bigger than this will be enclosed in CDATA XML "tag"
-define(CDATA_BINARY_THRESHOLD, 50).
element_to_string(El) ->
case El of
{xmlelement, Name, Attrs, Els} ->
@ -31,13 +34,16 @@ element_to_string(El) ->
true ->
[$<, Name, attrs_to_list(Attrs), $/, $>]
end;
{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) ->
%% if they are long enough to be worth it.
{xmlcdata, CData} when binary(CData), size(CData) > ?CDATA_BINARY_THRESHOLD ->
CDATA1 = <<"<![CDATA[">>,
CDATA2 = <<"]]>">>,
concat_binary([CDATA1, CData, CDATA2])
concat_binary([CDATA1, CData, CDATA2]);
%% We crypt list and short binaries (implies a conversion to
%% list).
{xmlcdata, CData} ->
crypt(CData)
end.
attrs_to_list(Attrs) ->