Fixed various unicode issue related to query and form parameters.

(Especially for the multipart/form-data encoding.)
Factorized code related to smart parameters computing (handling list , table, ...) in WSF_VALUE_UTILITIES.
Fixed an issue with percent_encoded_path_info computation from request_uri.
Fixed issue with cookie addition having same cookie name.
Fixed unicode support for uploaded file.
WSF_STRING is reusing WSF_PERCENT_ENCODER.
Use unicode output for WSF_DEBUG_HANDLER.
Code cleaning
This commit is contained in:
2015-11-05 21:32:24 +01:00
parent dde6a0b7de
commit 50ba8ca703
14 changed files with 329 additions and 362 deletions

View File

@@ -34,10 +34,10 @@ feature -- Access
feature -- Element change
change_name (a_name: like name)
-- <Precursor>
do
name := url_decoded_string (a_name)
ensure then
a_name.same_string (url_encoded_name)
name := a_name
url_encoded_name := url_encoded_string (a_name)
end
feature -- Status report
@@ -71,7 +71,7 @@ feature -- Visitor
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -89,10 +89,9 @@ feature -- Access
feature -- Element change
change_name (a_name: like name)
-- <Precursor>
do
name := a_name
ensure then
a_name.same_string (name)
end
feature -- Status report
@@ -180,7 +179,7 @@ invariant
string_values_not_empty: values.count >= 1
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -16,17 +16,24 @@ inherit
end
create
make
make,
make_with_percent_encoded_values
convert
string_representation: {READABLE_STRING_32, STRING_32}
feature {NONE} -- Initialization
make (a_name: READABLE_STRING_8; a_string: READABLE_STRING_8)
make (a_name: READABLE_STRING_GENERAL; a_string: READABLE_STRING_GENERAL)
do
url_encoded_name := utf_8_percent_encoded_string (a_name)
url_encoded_value := utf_8_percent_encoded_string (a_string)
url_encoded_name := url_encoded_string (a_name)
url_encoded_value := url_encoded_string (a_string)
end
make_with_percent_encoded_values (a_encoded_name: READABLE_STRING_8; a_encoded_value: READABLE_STRING_8)
do
url_encoded_name := a_encoded_name
url_encoded_value := a_encoded_value
end
feature -- Access
@@ -105,11 +112,10 @@ feature -- Status report
feature -- Element change
change_name (a_name: like name)
-- <Precursor>
do
internal_name := Void
url_encoded_name := a_name
ensure then
a_name.same_string (url_encoded_name)
internal_name := a_name
url_encoded_name := url_encoded_string (a_name)
end
feature -- Helper
@@ -147,89 +153,8 @@ feature -- Visitor
vis.process_string (Current)
end
feature {NONE} -- Implementation
utf_8_percent_encoded_string (s: READABLE_STRING_8): READABLE_STRING_8
-- Percent-encode the UTF-8 sequence characters from UTF-8 encoded `s' and
-- return the Result.
local
s8: STRING_8
i, n, nb: INTEGER
do
-- First check if there are such UTF-8 character
-- If it has, convert them and return a new object as Result
-- otherwise return `s' directly to avoid creating a new object
from
i := 1
n := s.count
nb := 0
until
i > n
loop
if s.code (i) > 0x7F then -- >= 128
nb := nb + 1
end
i := i + 1
end
if nb > 0 then
create s8.make (s.count + nb * 3)
utf_8_string_8_into_percent_encoded_string_8 (s, s8)
Result := s8
else
Result := s
end
end
utf_8_string_8_into_percent_encoded_string_8 (s: READABLE_STRING_8; a_result: STRING_8)
-- Copy STRING_32 corresponding to UTF-8 sequence `s' appended into `a_result'.
local
i: INTEGER
n: INTEGER
c: NATURAL_32
do
from
n := s.count
a_result.grow (a_result.count + n)
until
i >= n
loop
i := i + 1
c := s.code (i)
if c <= 0x7F then
-- 0xxxxxxx
a_result.append_code (c)
elseif c <= 0xDF then
-- 110xxxxx 10xxxxxx
url_encoder.append_percent_encoded_character_code_to (c, a_result)
i := i + 1
if i <= n then
url_encoder.append_percent_encoded_character_code_to (s.code (i), a_result)
end
elseif c <= 0xEF then
-- 1110xxxx 10xxxxxx 10xxxxxx
url_encoder.append_percent_encoded_character_code_to (s.code (i), a_result)
i := i + 2
if i <= n then
url_encoder.append_percent_encoded_character_code_to (s.code (i - 1), a_result)
url_encoder.append_percent_encoded_character_code_to (s.code (i), a_result)
end
elseif c <= 0xF7 then
-- 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
url_encoder.append_percent_encoded_character_code_to (s.code (i), a_result)
i := i + 3
if i <= n then
url_encoder.append_percent_encoded_character_code_to (s.code (i - 2), a_result)
url_encoder.append_percent_encoded_character_code_to (s.code (i - 1), a_result)
url_encoder.append_percent_encoded_character_code_to (s.code (i), a_result)
end
else
a_result.append_code (c)
end
end
end
note
copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -17,23 +17,34 @@ inherit
ITERABLE [WSF_VALUE]
create
make
make,
make_with_percent_encoded_name
feature {NONE} -- Initialization
make (a_name: READABLE_STRING_8)
make (a_name: READABLE_STRING_GENERAL)
do
name := url_decoded_string (a_name)
url_encoded_name := a_name
create values.make (5)
name := a_name.as_string_32
url_encoded_name := url_encoded_string (a_name)
create values.make (3)
end
make_with_percent_encoded_name (a_encoded_name: READABLE_STRING_8)
do
url_encoded_name := a_encoded_name
name := url_decoded_string (a_encoded_name)
create values.make (3)
end
feature -- Access
name: READABLE_STRING_32
-- Parameter name
-- <Precursor>
--| Note that the value might be html encoded as well
--| this is the application responsibility to html decode it
url_encoded_name: READABLE_STRING_8
-- URL encoded string of `name'.
first_value: detachable WSF_VALUE
-- First value if any.
@@ -59,13 +70,16 @@ feature -- Access
end
values: HASH_TABLE [WSF_VALUE, STRING_32]
-- Associated items values, indexed by unicode name.
value (k: READABLE_STRING_GENERAL): detachable WSF_VALUE
-- Value associated with name `k'.
do
Result := values.item (k.to_string_32)
end
count: INTEGER
-- Number of values.
do
Result := values.count
end
@@ -77,14 +91,15 @@ feature -- Access
Result := first_name
end
feature -- Element change
feature -- Element change
change_name (a_name: like name)
-- <Precursor>
do
name := url_decoded_string (a_name)
url_encoded_name := a_name
ensure then
a_name.same_string (url_encoded_name)
name := a_name
url_encoded_name := url_encoded_string (a_name)
end
feature -- Status report
@@ -217,7 +232,7 @@ feature -- Visitor
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -15,17 +15,27 @@ inherit
end
create
make
make,
make_with_percent_encoded_values
feature {NONE} -- Initialization
make (a_name: READABLE_STRING_8; n: like filename; t: like content_type; s: like size)
make (a_name: READABLE_STRING_GENERAL; a_filename: READABLE_STRING_GENERAL; a_content_type: like content_type; a_size: like size)
do
name := url_decoded_string (a_name)
url_encoded_name := a_name
filename := n
content_type := t
size := s
name := a_name.as_string_32
url_encoded_name := url_encoded_string (a_name)
filename := a_filename.as_string_32
content_type := a_content_type
size := a_size
end
make_with_percent_encoded_values (a_encoded_name: READABLE_STRING_8; a_filename: READABLE_STRING_GENERAL; a_content_type: like content_type; a_size: like size)
do
name := url_decoded_string (a_encoded_name)
url_encoded_name := a_encoded_name
filename := a_filename.as_string_32
content_type := a_content_type
size := a_size
end
feature -- Access
@@ -65,11 +75,10 @@ feature -- Status report
feature -- Element change
change_name (a_name: like name)
-- <Precursor>
do
name := url_decoded_string (a_name)
url_encoded_name := a_name
ensure then
a_name.same_string (url_encoded_name)
name := a_name
url_encoded_name := url_encoded_string (a_name)
end
feature -- Status report
@@ -99,7 +108,7 @@ feature -- Visitor
feature -- Access: Uploaded File
filename: STRING
filename: STRING_32
-- original filename
safe_filename: STRING
@@ -182,7 +191,7 @@ feature -- Basic operation
if f.exists then
f.rename_file (a_destination)
Result := True
end
end
end
ensure
removed: not exists
@@ -241,7 +250,7 @@ feature -- Element change
end
note
copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -36,8 +36,10 @@ feature -- Access
feature -- Element change
change_name (a_name: like name)
-- Change parameter name
-- Change parameter `name'.
deferred
ensure
name_changed: a_name.same_string (name)
end
feature -- Status report
@@ -128,7 +130,7 @@ feature -- Visitor
end
note
copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software