mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +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:
parent
78751e78c0
commit
5b4e116cfd
@ -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: ' entity replaced by ' Should work more
|
||||
|
@ -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
|
||||
$& -> "&";
|
||||
$< -> "<";
|
||||
$> -> ">";
|
||||
$" -> """;
|
||||
$' -> "'";
|
||||
_ -> 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
|
||||
|
@ -111,7 +111,7 @@ crypt(S) when is_list(S) ->
|
||||
$< -> "<";
|
||||
$> -> ">";
|
||||
$" -> """;
|
||||
$' -> "'";
|
||||
$' -> "'";
|
||||
_ -> C
|
||||
end || C <- S];
|
||||
crypt(S) when is_binary(S) ->
|
||||
|
Loading…
Reference in New Issue
Block a user