25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

* src/web/ejabberd_http.erl: Added separate version of

element_to_string for HTML encoding
* src/xml.erl: Reverted previous change

SVN Revision: 722
This commit is contained in:
Alexey Shchepin 2007-02-04 16:04:40 +00:00
parent 78751e78c0
commit 5b4e116cfd
3 changed files with 41 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2007-02-04 Alexey Shchepin <alexey@sevcom.net>
* src/web/ejabberd_http.erl: Added separate version of
element_to_string for HTML encoding
* src/xml.erl: Reverted previous change
2007-02-04 Mickael Remond <mickael.remond@process-one.net>
* src/xml.erl: &apos; entity replaced by &#39; Should work more

View File

@ -366,10 +366,10 @@ make_xhtml_output(State, Status, Headers, XHTML) ->
Data = case lists:member(html, Headers) of
true ->
list_to_binary([?HTML_DOCTYPE,
xml:element_to_string(XHTML)]);
element_to_string(XHTML)]);
_ ->
list_to_binary([?XHTML_DOCTYPE,
xml:element_to_string(XHTML)])
element_to_string(XHTML)])
end,
Headers1 = case lists:keysearch("Content-Type", 1, Headers) of
{value, _} ->
@ -449,6 +449,38 @@ parse_lang(Langs) ->
"en"
end.
element_to_string(El) ->
case El of
{xmlelement, Name, Attrs, Els} ->
if
Els /= [] ->
[$<, Name, attrs_to_list(Attrs), $>,
[element_to_string(E) || E <- Els],
$<, $/, Name, $>];
true ->
[$<, Name, attrs_to_list(Attrs), $/, $>]
end;
{xmlcdata, CData} ->
crypt(CData)
end.
attrs_to_list(Attrs) ->
[attr_to_list(A) || A <- Attrs].
attr_to_list({Name, Value}) ->
[$\s, crypt(Name), $=, $", crypt(Value), $"].
crypt(S) when is_list(S) ->
[case C of
$& -> "&amp;";
$< -> "&lt;";
$> -> "&gt;";
$" -> "&quot;";
$' -> "&#39;";
_ -> C
end || C <- S];
crypt(S) when is_binary(S) ->
crypt(binary_to_list(S)).
% Code below is taken (with some modifications) from the yaws webserver, which

View File

@ -111,7 +111,7 @@ crypt(S) when is_list(S) ->
$< -> "&lt;";
$> -> "&gt;";
$" -> "&quot;";
$' -> "&#39;";
$' -> "&apos;";
_ -> C
end || C <- S];
crypt(S) when is_binary(S) ->