mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-08 21:43:07 +02: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:
parent
15eee1c604
commit
af33f13371
|
@ -1,5 +1,8 @@
|
||||||
2007-07-30 Mickael Remond <mickael.remond@process-one.net>
|
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/tls/tls_drv.c: Sends the entire certificate chain (EJAB-209).
|
||||||
|
|
||||||
* src/acl.erl: Remove compilation warnings (EJAB-290).
|
* src/acl.erl: Remove compilation warnings (EJAB-290).
|
||||||
|
|
14
src/xml.erl
14
src/xml.erl
|
@ -20,6 +20,9 @@
|
||||||
get_path_s/2,
|
get_path_s/2,
|
||||||
replace_tag_attr/3]).
|
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) ->
|
element_to_string(El) ->
|
||||||
case El of
|
case El of
|
||||||
{xmlelement, Name, Attrs, Els} ->
|
{xmlelement, Name, Attrs, Els} ->
|
||||||
|
@ -31,13 +34,16 @@ element_to_string(El) ->
|
||||||
true ->
|
true ->
|
||||||
[$<, Name, attrs_to_list(Attrs), $/, $>]
|
[$<, Name, attrs_to_list(Attrs), $/, $>]
|
||||||
end;
|
end;
|
||||||
{xmlcdata, CData} when list(CData) ->
|
|
||||||
crypt(CData);
|
|
||||||
%% We do not crypt CDATA binary, but we enclose it in XML 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[">>,
|
CDATA1 = <<"<![CDATA[">>,
|
||||||
CDATA2 = <<"]]>">>,
|
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.
|
end.
|
||||||
|
|
||||||
attrs_to_list(Attrs) ->
|
attrs_to_list(Attrs) ->
|
||||||
|
|
Loading…
Reference in New Issue
Block a user