aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test_server/src/test_server_ctrl.erl
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2013-02-12 14:31:24 +0100
committerSiri Hansen <[email protected]>2013-03-04 11:01:13 +0100
commit79406f338464a9ba94c8531c8a7a44a01ad14b42 (patch)
treefb84bd49dbf5157813987d3a3a0c5022dca58ef8 /lib/test_server/src/test_server_ctrl.erl
parentdab88ad5dc3a8dd23a898953fe48366d865074ea (diff)
downloadotp-79406f338464a9ba94c8531c8a7a44a01ad14b42.tar.gz
otp-79406f338464a9ba94c8531c8a7a44a01ad14b42.tar.bz2
otp-79406f338464a9ba94c8531c8a7a44a01ad14b42.zip
[test_server] Fix encoding of HTML file references to work on windows
The URI encoding when in unicode file name mode did not preserve @, : and /, and thus some links were did not work on windows (think c:/). This has been corrected.
Diffstat (limited to 'lib/test_server/src/test_server_ctrl.erl')
-rw-r--r--lib/test_server/src/test_server_ctrl.erl33
1 files changed, 15 insertions, 18 deletions
diff --git a/lib/test_server/src/test_server_ctrl.erl b/lib/test_server/src/test_server_ctrl.erl
index 5d4d392166..950ff862c6 100644
--- a/lib/test_server/src/test_server_ctrl.erl
+++ b/lib/test_server/src/test_server_ctrl.erl
@@ -5375,31 +5375,28 @@ uri_encode(File,Encoding) ->
Components = filename:split(File),
filename:join([uri_encode_comp(C,Encoding) || C <- Components]).
-uri_encode_comp("/",_) ->
- "/";
-uri_encode_comp(Chars,utf8) ->
- http_uri:encode(Chars);
-uri_encode_comp(Chars,latin1) ->
- do_uri_encode(Chars).
-
-%% Encode a file reference to a latin1 filename so it can be inserted
-%% in a utf8 encoded HTML file.
-%% This does the same as http_uri:encode/1, except it also encodes all
-%% characters >127 - i.e. latin1 but not ASCII.
-do_uri_encode([Char|Chars]) ->
- case Char>127 orelse sets:is_element(Char, reserved()) of
+%% Encode the reference to a "filename of the given encoding" so it
+%% can be inserted in a utf8 encoded HTML file.
+%% This does almost the same as http_uri:encode/1, except
+%% 1. it does not convert @, : and / (in order to preserve nodename and c:/)
+%% 2. if the file name is in latin1, it also encodes all
+%% characters >127 - i.e. latin1 but not ASCII.
+uri_encode_comp([Char|Chars],Encoding) ->
+ Reserved = sets:is_element(Char, reserved()),
+ case (Char>127 andalso Encoding==latin1) orelse Reserved of
true ->
- [ $% | http_util:integer_to_hexlist(Char)] ++ do_uri_encode(Chars);
+ [ $% | http_util:integer_to_hexlist(Char)] ++
+ uri_encode_comp(Chars,Encoding);
false ->
- [Char | do_uri_encode(Chars)]
+ [Char | uri_encode_comp(Chars,Encoding)]
end;
-do_uri_encode([]) ->
+uri_encode_comp([],_) ->
[].
%% Copied from http_uri.erl, but slightly modified
-%% (not converting @ and :)
+%% (not converting @, : and /)
reserved() ->
- sets:from_list([$;, $&, $=, $+, $,, $/, $?,
+ sets:from_list([$;, $&, $=, $+, $,, $?,
$#, $[, $], $<, $>, $\", ${, $}, $|,
$\\, $', $^, $%, $ ]).