aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_server
diff options
context:
space:
mode:
authorPéter Dimitrov <[email protected]>2018-04-17 09:39:04 +0200
committerPéter Dimitrov <[email protected]>2018-04-18 16:28:23 +0200
commit35009ed9aaf3fd52d9be11777b51abbef3c7cf75 (patch)
treef2ebd717524cf207b330c07163c5bef4b21108b2 /lib/inets/src/http_server
parent0bcba3f1c9afc9a4164bf78641844a293768a7ec (diff)
downloadotp-35009ed9aaf3fd52d9be11777b51abbef3c7cf75.tar.gz
otp-35009ed9aaf3fd52d9be11777b51abbef3c7cf75.tar.bz2
otp-35009ed9aaf3fd52d9be11777b51abbef3c7cf75.zip
inets: Fix handling of relative paths in script_alias
- Add function for converting relative paths to absolute using the server_root property. Change-Id: If9b521e4444a3382f7e5449b187c1c0ebbb3d0f3
Diffstat (limited to 'lib/inets/src/http_server')
-rw-r--r--lib/inets/src/http_server/mod_alias.erl22
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/inets/src/http_server/mod_alias.erl b/lib/inets/src/http_server/mod_alias.erl
index 0333076546..8f0b92710e 100644
--- a/lib/inets/src/http_server/mod_alias.erl
+++ b/lib/inets/src/http_server/mod_alias.erl
@@ -163,28 +163,24 @@ longest_match([], _RequestURI, _LongestNo, LongestAlias) ->
real_script_name(_ConfigDB, _RequestURI, []) ->
not_a_script;
-
-real_script_name(ConfigDB, RequestURI, [{MP,Replacement} | Rest])
- when element(1, MP) =:= re_pattern ->
- case re:run(RequestURI, MP, [{capture, none}]) of
- match ->
- ActualName =
- re:replace(RequestURI, MP, Replacement, [{return,list}]),
- httpd_util:split_script_path(default_index(ConfigDB, ActualName));
- nomatch ->
- real_script_name(ConfigDB, RequestURI, Rest)
- end;
-
real_script_name(ConfigDB, RequestURI, [{FakeName,RealName} | Rest]) ->
case re:run(RequestURI, "^" ++ FakeName, [{capture, none}]) of
match ->
- ActualName =
+ ActualName0 =
re:replace(RequestURI, "^" ++ FakeName, RealName, [{return,list}]),
+ ActualName = abs_script_path(ConfigDB, ActualName0),
httpd_util:split_script_path(default_index(ConfigDB, ActualName));
nomatch ->
real_script_name(ConfigDB, RequestURI, Rest)
end.
+%% ERL-574: relative path in script_alias property results in malformed url
+abs_script_path(ConfigDB, [$.|_] = RelPath) ->
+ Root = httpd_util:lookup(ConfigDB, server_root),
+ Root ++ "/" ++ RelPath;
+abs_script_path(_, RelPath) ->
+ RelPath.
+
%% default_index
default_index(ConfigDB, Path) ->