Fixed a previously character changes in WSF_REQUEST (related to safe_filename), and modified the implementation to use inspect

Fixed the request_content_type computation
Cosmetic in REQUEST_RESOURCE_HANDLER_HELPER
This commit is contained in:
Jocelyn Fiat
2011-10-27 16:00:33 +02:00
parent 8e4e7a5084
commit 0d637d478a
3 changed files with 88 additions and 37 deletions

View File

@@ -167,7 +167,7 @@ feature -- Handle responses
Result := Void
end
handle_bad_request_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE )
handle_bad_request_response (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE )
local
h : WSF_HEADER
do
@@ -182,7 +182,7 @@ feature -- Handle responses
end
handle_precondition_fail_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE )
handle_precondition_fail_response (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE )
local
h : WSF_HEADER
do
@@ -196,7 +196,7 @@ feature -- Handle responses
res.write_string (a_description)
end
handle_internal_server_error (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE )
handle_internal_server_error (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE )
local
h : WSF_HEADER
do
@@ -224,7 +224,7 @@ feature -- Handle responses
res.write_string (a_description)
end
handle_method_not_allowed_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
handle_method_not_allowed_response (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
local
h : WSF_HEADER
do
@@ -238,7 +238,7 @@ feature -- Handle responses
res.write_string (a_description)
end
handle_resource_not_found_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
handle_resource_not_found_response (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
local
h : WSF_HEADER
do
@@ -253,7 +253,7 @@ feature -- Handle responses
end
handle_resource_not_modified_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
handle_resource_not_modified_response (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
local
h : WSF_HEADER
do
@@ -269,7 +269,7 @@ feature -- Handle responses
end
handle_resource_conflict_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
handle_resource_conflict_response (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
local
h : WSF_HEADER
do

View File

@@ -73,11 +73,17 @@ feature -- Query
local
s: detachable READABLE_STRING_8
i,n: INTEGER
l_accept_lst: detachable ARRAYED_LIST [READABLE_STRING_8]
do
l_accept_lst := accepted_content_types (request)
if attached request.content_type as ct then
Result := ct
if l_accept_lst /= Void then
l_accept_lst.put_front (ct)
else
if attached accepted_content_types (request) as l_accept_lst then
Result := ct
end
end
if Result = Void and l_accept_lst /= Void then
from
l_accept_lst.start
until
@@ -103,7 +109,6 @@ feature -- Query
end
end
end
end
feature -- Query

View File

@@ -1205,11 +1205,7 @@ feature {NONE} -- Temporary File handling
local
c: CHARACTER
i, n, p: INTEGER
l_accentued, l_non_accentued: STRING
do
l_accentued := "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
l_non_accentued := "AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy"
--| Compute safe filename, to avoid creating impossible filename, or dangerous one
from
i := 1
@@ -1225,9 +1221,59 @@ feature {NONE} -- Temporary File handling
when 'A' .. 'Z', 'a' .. 'z', '0' .. '9' then
Result.extend (c)
else
p := l_accentued.index_of (c, 1)
if p > 0 then
Result.extend (l_non_accentued[p])
inspect c
when 'À' then Result.extend ('A')
when 'Á' then Result.extend ('A')
when 'Â' then Result.extend ('A')
when 'Ã' then Result.extend ('A')
when 'Ä' then Result.extend ('A')
when 'Å' then Result.extend ('A')
when 'Ç' then Result.extend ('C')
when 'È' then Result.extend ('E')
when 'É' then Result.extend ('E')
when 'Ê' then Result.extend ('E')
when 'Ë' then Result.extend ('E')
when 'Ì' then Result.extend ('I')
when 'Í' then Result.extend ('I')
when 'Î' then Result.extend ('I')
when 'Ï' then Result.extend ('I')
when 'Ò' then Result.extend ('O')
when 'Ó' then Result.extend ('O')
when 'Ô' then Result.extend ('O')
when 'Õ' then Result.extend ('O')
when 'Ö' then Result.extend ('O')
when 'Ù' then Result.extend ('U')
when 'Ú' then Result.extend ('U')
when 'Û' then Result.extend ('U')
when 'Ü' then Result.extend ('U')
when 'Ý' then Result.extend ('Y')
when 'à' then Result.extend ('a')
when 'á' then Result.extend ('a')
when 'â' then Result.extend ('a')
when 'ã' then Result.extend ('a')
when 'ä' then Result.extend ('a')
when 'å' then Result.extend ('a')
when 'ç' then Result.extend ('c')
when 'è' then Result.extend ('e')
when 'é' then Result.extend ('e')
when 'ê' then Result.extend ('e')
when 'ë' then Result.extend ('e')
when 'ì' then Result.extend ('i')
when 'í' then Result.extend ('i')
when 'î' then Result.extend ('i')
when 'ï' then Result.extend ('i')
when 'ð' then Result.extend ('o')
when 'ò' then Result.extend ('o')
when 'ó' then Result.extend ('o')
when 'ô' then Result.extend ('o')
when 'õ' then Result.extend ('o')
when 'ö' then Result.extend ('o')
when 'ù' then Result.extend ('u')
when 'ú' then Result.extend ('u')
when 'û' then Result.extend ('u')
when 'ü' then Result.extend ('u')
when 'ý' then Result.extend ('y')
when 'ÿ' then Result.extend ('y')
else
Result.extend ('-')
end