From cc4ef1a5750597777340fa97b824628f9d607e10 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 12 Jun 2013 18:00:55 +0200 Subject: [PATCH] Better support for unicode path and values. Added WSF_REQUEST.percent_encoded_path_info: READABLE_STRING_8 to keep url encoded path info, as it is useful for specific component The router is now using WSF_REQUEST.percent_encoded_path_info since URI_TEMPLATE are handling URI (and not IRI) this fixes an issue with unicode path parameters. This should not break existing code, and this fixes various unicode related issues related to PATH parameter and path info but also any component using file names. (required EiffelStudio >= 7.2) --- .../step_4/hello/src/user_message_handler.e | 7 +- .../src/http_file_extension_mime_mapping.e | 18 +- .../wsf_router_self_documentation_message.e | 2 +- .../starts_with/wsf_starts_with_handler.e | 4 +- .../starts_with/wsf_starts_with_mapping_i.e | 2 +- .../uri_template/wsf_uri_template_mapping_i.e | 4 +- .../wsf/router/wsf_file_system_handler.e | 175 +++--- .../server/wsf/router/wsf_router_mapping.e | 4 +- .../server/wsf/session/wsf_cookie_session.e | 16 +- .../wsf/session/wsf_fs_session_manager.e | 27 +- .../shared_wsf_percent_encoder.e | 28 + .../src/implementation/wsf_percent_encoder.e | 523 ++++++++++++++++++ .../src/request/value/wsf_multiple_string.e | 2 +- .../server/wsf/src/request/value/wsf_string.e | 16 +- .../wsf/src/request/value/wsf_uploaded_file.e | 38 +- library/server/wsf/src/request/wsf_value.e | 26 +- .../wsf/src/response/wsf_download_response.e | 80 ++- .../wsf/src/response/wsf_file_response.e | 72 ++- .../service/wsf_service_launcher_options.e | 39 +- .../wsf_service_launcher_options_from_ini.e | 24 +- library/server/wsf/src/wsf_request.e | 188 ++++--- library/text/encoder/encoder-safe.ecf | 12 - library/text/encoder/encoder.ecf | 12 - ...der_helper.e => shared_utf8_url_encoder.e} | 28 +- .../src/spec/before_70/utf8_encoder_helper.e | 73 --- library/text/encoder/src/utf8_encoder.e | 35 +- library/text/encoder/src/utf8_url_encoder.e | 50 +- tools/bin/ecf_updater.exe | Bin 0 -> 2256384 bytes 28 files changed, 1056 insertions(+), 449 deletions(-) create mode 100644 library/server/wsf/src/implementation/shared_wsf_percent_encoder.e create mode 100644 library/server/wsf/src/implementation/wsf_percent_encoder.e rename library/text/encoder/src/{spec/70/utf8_encoder_helper.e => shared_utf8_url_encoder.e} (50%) delete mode 100644 library/text/encoder/src/spec/before_70/utf8_encoder_helper.e create mode 100644 tools/bin/ecf_updater.exe diff --git a/examples/tutorial/step_4/hello/src/user_message_handler.e b/examples/tutorial/step_4/hello/src/user_message_handler.e index 12a6a0e8..5e1b3f5e 100644 --- a/examples/tutorial/step_4/hello/src/user_message_handler.e +++ b/examples/tutorial/step_4/hello/src/user_message_handler.e @@ -10,6 +10,10 @@ class inherit WSF_URI_TEMPLATE_RESPONSE_HANDLER + SHARED_WSF_PERCENT_ENCODER + rename + percent_encoder as url_encoder + end feature -- Access @@ -75,7 +79,8 @@ feature -- Access url_encoded_string (s: READABLE_STRING_32): STRING_8 do - Result := (create {UTF8_URL_ENCODER}).encoded_string (s) + create Result.make (s.count) + url_encoder.append_percent_encoded_string_to (s, Result) end html_decoded_string (v: READABLE_STRING_32): READABLE_STRING_32 diff --git a/library/network/protocol/http/src/http_file_extension_mime_mapping.e b/library/network/protocol/http/src/http_file_extension_mime_mapping.e index 387e8ed4..043e0fc1 100644 --- a/library/network/protocol/http/src/http_file_extension_mime_mapping.e +++ b/library/network/protocol/http/src/http_file_extension_mime_mapping.e @@ -33,8 +33,7 @@ feature {NONE} -- Initialization -- Create with no mapping -- but one can use `map' to add new mapping do - create mapping.make (n) - mapping.compare_objects + create mapping.make_caseless (n) end make_default @@ -43,9 +42,8 @@ feature {NONE} -- Initialization local m: like mapping do - create m.make (40) + create m.make_caseless (40) mapping := m - m.compare_objects m.force (text_css, "css") m.force (text_html, "html") m.force (text_xml, "xml") @@ -74,13 +72,13 @@ feature {NONE} -- Initialization m.force (text_plain, "txt") end - make_from_file (fn: READABLE_STRING_8) + make_from_file (fn: READABLE_STRING_GENERAL) -- Create with mime.types file -- One can use `map' to add new mapping local f: RAW_FILE do - create f.make (fn) + create f.make_with_name (fn) if f.exists and then f.is_readable then make_empty (50) f.open_read @@ -128,7 +126,7 @@ feature {NONE} -- Initialization feature -- Access - mime_type (ext: READABLE_STRING_8): detachable READABLE_STRING_8 + mime_type (ext: READABLE_STRING_GENERAL): detachable READABLE_STRING_8 -- Mime type for extension `ext' do Result := mapping.item (ext.as_lower) @@ -136,7 +134,7 @@ feature -- Access feature -- Element change - map (e: READABLE_STRING_8; t: READABLE_STRING_8) + map (e: READABLE_STRING_GENERAL; t: READABLE_STRING_8) -- Add mapping extension `e' to mime type `t' do mapping.force (t, e.as_lower) @@ -220,13 +218,13 @@ feature {NONE} -- Implementation feature {NONE} -- Extension MIME mapping - mapping: HASH_TABLE [READABLE_STRING_8, READABLE_STRING_8] + mapping: STRING_TABLE [READABLE_STRING_8] invariant mapping_keys_are_lowercase: across mapping as c all c.key.same_string (c.key.as_lower) end note - copyright: "2011-2011, Eiffel Software and others" + copyright: "2011-2013, Jocelyn Fiat, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/router/documentation/wsf_router_self_documentation_message.e b/library/server/wsf/router/documentation/wsf_router_self_documentation_message.e index 21d4bfc4..acd21662 100644 --- a/library/server/wsf/router/documentation/wsf_router_self_documentation_message.e +++ b/library/server/wsf/router/documentation/wsf_router_self_documentation_message.e @@ -137,7 +137,7 @@ feature {WSF_RESPONSE} -- Output debug l_description.append ("

Meta Information