Replace any multiple slash sequence by a single slash character for PATH_INFO.

This commit is contained in:
2014-07-02 11:36:43 +02:00
parent 446c692f97
commit 1b4b50ee80
2 changed files with 34 additions and 6 deletions

View File

@@ -169,7 +169,6 @@ feature -- Request processing
if p > 0 then if p > 0 then
l_path_info.keep_head (p - 1) l_path_info.keep_head (p - 1)
end end
env.force (enc.decoded_utf_8_string (l_path_info), "PATH_INFO")
env.force (l_base, "SCRIPT_NAME") env.force (l_base, "SCRIPT_NAME")
else else
-- This should not happen, this means the `base' is not correctly set. -- This should not happen, this means the `base' is not correctly set.
@@ -183,9 +182,11 @@ feature -- Request processing
else else
l_path_info := l_request_uri.string l_path_info := l_request_uri.string
end end
env.force (enc.decoded_utf_8_string (l_path_info), "PATH_INFO")
env.force ("", "SCRIPT_NAME") env.force ("", "SCRIPT_NAME")
end end
--| Strip multiple slashes "////abc/def///end////" to "/abc/def/end/" ?
convert_multiple_slashes_to_single (l_path_info)
env.force (enc.decoded_utf_8_string (l_path_info), "PATH_INFO")
end end
callback.process_request (env, a_handler.request_header, a_socket) callback.process_request (env, a_handler.request_header, a_socket)
@@ -213,6 +214,35 @@ feature -- Request processing
end end
end end
feature {NONE} -- Implementation
convert_multiple_slashes_to_single (s: STRING_8)
-- Replace multiple slashes sequence by a single slash character.
local
i,n: INTEGER
do
from
i := 1
n := s.count
until
i > n
loop
if s[i] = '/' then
-- Remove following slashes '/'.
from
i := i + 1
until
i > n or s[i] /= '/'
loop
s.remove (i)
n := n - 1
end
else
i := i + 1
end
end
end
note note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -387,11 +387,8 @@ feature {NONE} -- Element change: CGI meta parameter related to PATH_INFO
end end
l_request_uri := s8 l_request_uri := s8
end end
--| FIXME: should it strip "////abc/def" to "/abc/def" ?
--| Not sure why this was done before.
-- l_request_uri := single_slash_starting_string (l_request_uri)
request_uri := l_request_uri
set_meta_string_variable ({WGI_META_NAMES}.request_uri, l_request_uri) set_meta_string_variable ({WGI_META_NAMES}.request_uri, l_request_uri)
request_uri := l_request_uri
end end
set_orig_path_info (s: READABLE_STRING_8) set_orig_path_info (s: READABLE_STRING_8)
@@ -418,6 +415,7 @@ feature {NONE} -- Element change: CGI meta parameter related to PATH_INFO
l_path_info: STRING l_path_info: STRING
do do
l_path_info := path_info l_path_info := path_info
--| Warning --| Warning
--| on IIS: we might have PATH_INFO = /sample.exe/foo/bar --| on IIS: we might have PATH_INFO = /sample.exe/foo/bar
--| on apache: PATH_INFO = /foo/bar --| on apache: PATH_INFO = /foo/bar