Fixed unicode support for uploaded file.
Code cleaning.
This commit is contained in:
@@ -138,10 +138,12 @@ feature {NONE} -- Implementation: Form analyzer
|
|||||||
local
|
local
|
||||||
n, i,p, b,e: INTEGER
|
n, i,p, b,e: INTEGER
|
||||||
l_name, l_filename, l_content_type: detachable STRING_8
|
l_name, l_filename, l_content_type: detachable STRING_8
|
||||||
|
l_unicode_name: READABLE_STRING_32
|
||||||
l_header: detachable STRING_8
|
l_header: detachable STRING_8
|
||||||
l_content: detachable STRING_8
|
l_content: detachable STRING_8
|
||||||
l_line: detachable STRING_8
|
l_line: detachable STRING_8
|
||||||
l_up_file: WSF_UPLOADED_FILE
|
l_up_file: WSF_UPLOADED_FILE
|
||||||
|
utf: UTF_CONVERTER
|
||||||
do
|
do
|
||||||
from
|
from
|
||||||
p := 1
|
p := 1
|
||||||
@@ -234,8 +236,9 @@ feature {NONE} -- Implementation: Form analyzer
|
|||||||
if l_content_type = Void then
|
if l_content_type = Void then
|
||||||
l_content_type := default_content_type
|
l_content_type := default_content_type
|
||||||
end
|
end
|
||||||
create l_up_file.make (l_name, l_filename, l_content_type, l_content.count)
|
l_unicode_name := utf.utf_8_string_8_to_string_32 (l_name)
|
||||||
add_value_to_table (l_name, l_up_file, vars)
|
create l_up_file.make (l_unicode_name, utf.utf_8_string_8_to_escaped_string_32 (l_filename), l_content_type, l_content.count)
|
||||||
|
add_value_to_table (l_unicode_name, l_up_file, vars)
|
||||||
--| `l_up_file' might have a new name
|
--| `l_up_file' might have a new name
|
||||||
req.save_uploaded_file (l_up_file, l_content)
|
req.save_uploaded_file (l_up_file, l_content)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -15,17 +15,27 @@ inherit
|
|||||||
end
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make,
|
||||||
|
make_with_percent_encoded_values
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
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
|
do
|
||||||
name := url_decoded_string (a_name)
|
name := a_name.as_string_32
|
||||||
url_encoded_name := a_name
|
url_encoded_name := url_encoded_string (a_name)
|
||||||
filename := n
|
filename := a_filename.as_string_32
|
||||||
content_type := t
|
content_type := a_content_type
|
||||||
size := s
|
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
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
@@ -98,7 +108,7 @@ feature -- Visitor
|
|||||||
|
|
||||||
feature -- Access: Uploaded File
|
feature -- Access: Uploaded File
|
||||||
|
|
||||||
filename: STRING
|
filename: STRING_32
|
||||||
-- original filename
|
-- original filename
|
||||||
|
|
||||||
safe_filename: STRING
|
safe_filename: STRING
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ feature -- Smart parameter identification
|
|||||||
tb,ptb: detachable WSF_TABLE
|
tb,ptb: detachable WSF_TABLE
|
||||||
do
|
do
|
||||||
--| Check if this is a list format such as choice[] or choice[a] or even choice[a][] or choice[a][b][c]...
|
--| Check if this is a list format such as choice[] or choice[a] or even choice[a][] or choice[a][b][c]...
|
||||||
l_decoded_name := a_name.as_string_32 --url_encoder.decoded_string (a_name)
|
l_decoded_name := a_name.as_string_32
|
||||||
l_encoded_name := url_encoder.percent_encoded_string (l_decoded_name)
|
l_encoded_name := a_value.url_encoded_name
|
||||||
p := l_decoded_name.index_of ({CHARACTER_32}'[', 1)
|
p := l_decoded_name.index_of ({CHARACTER_32}'[', 1)
|
||||||
n := l_decoded_name
|
n := l_decoded_name
|
||||||
if p > 0 then
|
if p > 0 then
|
||||||
@@ -136,11 +136,13 @@ feature -- Smart parameter identification
|
|||||||
feature -- Factory
|
feature -- Factory
|
||||||
|
|
||||||
new_string_value (a_name: READABLE_STRING_GENERAL; a_value: READABLE_STRING_GENERAL): WSF_STRING
|
new_string_value (a_name: READABLE_STRING_GENERAL; a_value: READABLE_STRING_GENERAL): WSF_STRING
|
||||||
|
-- New WSF_STRING value built from unicode `a_name' and `a_value'.
|
||||||
do
|
do
|
||||||
create Result.make (a_name, a_value)
|
create Result.make (a_name, a_value)
|
||||||
end
|
end
|
||||||
|
|
||||||
new_string_value_with_percent_encoded_values (a_encoded_name: READABLE_STRING_8; a_encoded_value: READABLE_STRING_8): WSF_STRING
|
new_string_value_with_percent_encoded_values (a_encoded_name: READABLE_STRING_8; a_encoded_value: READABLE_STRING_8): WSF_STRING
|
||||||
|
-- New WSF_STRING value built from utf8+percent encoded `a_encoded_name' and `a_encoded_value'.
|
||||||
do
|
do
|
||||||
create Result.make_with_percent_encoded_values (a_encoded_name, a_encoded_value)
|
create Result.make_with_percent_encoded_values (a_encoded_name, a_encoded_value)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user