From a84f86d7a295816448f32bc19fc1de72c15b508b Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 20 Oct 2015 18:49:40 +0200 Subject: [PATCH] Addressed various unicode related issues. Note this is using recent changes from text_filter library. --- .../sqlite3/src/cms_storage_sqlite3.e | 28 ++++++++++++++---- .../handler/role/cms_admin_roles_handler.e | 2 +- .../handler/user/cms_admin_users_handler.e | 2 +- modules/blog/cms_blog.e | 4 +-- modules/blog/handler/blog_user_handler.e | 2 +- modules/node/content/cms_node.e | 4 +-- modules/node/content/cms_partial_node.e | 4 +-- modules/node/content_type/cms_page.e | 4 +-- .../handler/cms_node_type_webform_manager.e | 29 +++++++++++++------ .../node/persistence/cms_node_storage_sql.e | 2 +- src/persistence/sql/cms_storage_sql_i.e | 3 ++ 11 files changed, 58 insertions(+), 26 deletions(-) diff --git a/library/persistence/sqlite3/src/cms_storage_sqlite3.e b/library/persistence/sqlite3/src/cms_storage_sqlite3.e index 4c53138..0bcd73a 100644 --- a/library/persistence/sqlite3/src/cms_storage_sqlite3.e +++ b/library/persistence/sqlite3/src/cms_storage_sqlite3.e @@ -9,17 +9,20 @@ class inherit CMS_STORAGE_SQL redefine - sql_read_date_time, sql_read_integer_32 + sql_read_date_time, sql_read_integer_32, + sql_read_string_32 end CMS_CORE_STORAGE_SQL_I redefine - sql_read_date_time, sql_read_integer_32 + sql_read_date_time, sql_read_integer_32, + sql_read_string_32 end CMS_USER_STORAGE_SQL_I redefine - sql_read_date_time, sql_read_integer_32 + sql_read_date_time, sql_read_integer_32, + sql_read_string_32 end SQLITE_BIND_ARG_MARSHALLER @@ -227,6 +230,7 @@ feature -- Operation local k: READABLE_STRING_GENERAL k8: STRING + utf: UTF_CONVERTER do create Result.make (a_params.count) across @@ -236,11 +240,12 @@ feature -- Operation if k.is_valid_as_string_8 then k8 := k.as_string_8 else - k8 := (create {UTF_CONVERTER}).utf_32_string_to_utf_8_string_8 (k) + k8 := utf.utf_32_string_to_utf_8_string_8 (k) end if attached {DATE_TIME} ic.item as dt then - Result.force (new_binding_argument (date_time_to_string (dt), ":" + k8)) + elseif attached {READABLE_STRING_32} ic.item as s32 then + Result.force (new_binding_argument (utf.utf_32_string_to_utf_8_string_8 (s32), ":" + k8)) else Result.force (new_binding_argument (ic.item, ":" + k8)) end @@ -363,6 +368,19 @@ feature -- Access end end + sql_read_string_32 (a_index: INTEGER): detachable STRING_32 + -- + local + utf: UTF_CONVERTER + do + Result := Precursor (a_index) + if Result = Void then + if attached sql_read_string (a_index) as s8 then + Result := utf.utf_8_string_8_to_string_32 (s8) + end + end + end + sql_read_integer_32 (a_index: INTEGER): INTEGER_32 -- Retrieved value at `a_index' position in `item'. local diff --git a/modules/admin/handler/role/cms_admin_roles_handler.e b/modules/admin/handler/role/cms_admin_roles_handler.e index 229473e..aeedba8 100644 --- a/modules/admin/handler/role/cms_admin_roles_handler.e +++ b/modules/admin/handler/role/cms_admin_roles_handler.e @@ -93,7 +93,7 @@ feature -- HTTP Methods s.append ("") - s.append (u.name) + s.append (html_encoded (u.name)) s.append ("") s.append ("%N") end diff --git a/modules/admin/handler/user/cms_admin_users_handler.e b/modules/admin/handler/user/cms_admin_users_handler.e index d087c6c..4a47833 100644 --- a/modules/admin/handler/user/cms_admin_users_handler.e +++ b/modules/admin/handler/user/cms_admin_users_handler.e @@ -106,7 +106,7 @@ feature -- HTTP Methods s.append ("") - s.append (u.name) + s.append (html_encoded (u.name)) s.append ("") s.append ("%N") end diff --git a/modules/blog/cms_blog.e b/modules/blog/cms_blog.e index 2d2a6d3..78a0d14 100644 --- a/modules/blog/cms_blog.e +++ b/modules/blog/cms_blog.e @@ -50,10 +50,10 @@ feature -- Access feature -- Access: node - summary: detachable READABLE_STRING_8 + summary: detachable READABLE_STRING_32 -- A short summary of the node. - content: detachable READABLE_STRING_8 + content: detachable READABLE_STRING_32 -- Content of the node. format: detachable READABLE_STRING_8 diff --git a/modules/blog/handler/blog_user_handler.e b/modules/blog/handler/blog_user_handler.e index de1997f..8a50809 100644 --- a/modules/blog/handler/blog_user_handler.e +++ b/modules/blog/handler/blog_user_handler.e @@ -123,7 +123,7 @@ feature -- HTML Output do a_output.append ("

Posts from ") if attached user as l_user then - a_output.append (l_user.name) + a_output.append (html_encoded (l_user.name)) else a_output.append ("unknown user") end diff --git a/modules/node/content/cms_node.e b/modules/node/content/cms_node.e index 696d011..41ab55d 100644 --- a/modules/node/content/cms_node.e +++ b/modules/node/content/cms_node.e @@ -103,12 +103,12 @@ feature -- Access -- Full title of the node. -- Required! - summary: detachable READABLE_STRING_8 + summary: detachable READABLE_STRING_32 -- A short summary of the node. deferred end - content: detachable READABLE_STRING_8 + content: detachable READABLE_STRING_32 -- Content of the node. deferred end diff --git a/modules/node/content/cms_partial_node.e b/modules/node/content/cms_partial_node.e index 8ab6aa2..0cba1f6 100644 --- a/modules/node/content/cms_partial_node.e +++ b/modules/node/content/cms_partial_node.e @@ -33,10 +33,10 @@ feature -- Access: code feature -- Access: content - summary: detachable READABLE_STRING_8 + summary: detachable READABLE_STRING_32 -- A short summary of the node. - content: detachable READABLE_STRING_8 + content: detachable READABLE_STRING_32 -- Content of the node. format: detachable READABLE_STRING_8 diff --git a/modules/node/content_type/cms_page.e b/modules/node/content_type/cms_page.e index 5bb3cbd..d90f194 100644 --- a/modules/node/content_type/cms_page.e +++ b/modules/node/content_type/cms_page.e @@ -44,10 +44,10 @@ feature -- Access feature -- Access: content - summary: detachable READABLE_STRING_8 + summary: detachable READABLE_STRING_32 -- A short summary of the node. - content: detachable READABLE_STRING_8 + content: detachable READABLE_STRING_32 -- Content of the node. format: detachable READABLE_STRING_8 diff --git a/modules/node/handler/cms_node_type_webform_manager.e b/modules/node/handler/cms_node_type_webform_manager.e index 33da381..4876844 100644 --- a/modules/node/handler/cms_node_type_webform_manager.e +++ b/modules/node/handler/cms_node_type_webform_manager.e @@ -100,6 +100,7 @@ feature -- Forms ... local ti: WSF_FORM_TEXT_INPUT l_uri: detachable READABLE_STRING_8 + l_iri: detachable READABLE_STRING_32 do -- Path alias create ti.make ("path_alias") @@ -111,7 +112,8 @@ feature -- Forms ... if attached a_node.link as lnk then l_uri := lnk.location else - l_uri := percent_encoder.percent_decoded_string (response.api.location_alias (response.node_api.node_path (a_node))) + l_iri := percent_encoder.percent_decoded_string (response.api.location_alias (response.node_api.node_path (a_node))) + l_uri := l_iri.to_string_8 end ti.set_text_value (l_uri) ti.set_description ("Optionally specify an alternative URL path by which this content can be accessed. For example, type 'about' when writing an about page. Use a relative path or the URL alias won't work.") @@ -151,10 +153,9 @@ feature -- Forms ... end end - update_node (response: NODE_RESPONSE; fd: WSF_FORM_DATA; a_node: CMS_NODE) local - b,s: detachable READABLE_STRING_8 + b,s: detachable READABLE_STRING_32 f: detachable CONTENT_FORMAT do if attached fd.integer_item ("id") as l_id and then l_id > 0 then @@ -193,7 +194,7 @@ feature -- Forms ... new_node (response: NODE_RESPONSE; fd: WSF_FORM_DATA; a_node: detachable CMS_NODE): G -- local - b,s: detachable READABLE_STRING_8 + b,s: detachable READABLE_STRING_32 f: detachable CONTENT_FORMAT l_node: detachable like new_node do @@ -304,7 +305,7 @@ feature -- Output s.append ("
") if attached a_node.author as l_author then s.append (" by ") - s.append (l_author.name) + s.append (a_response.html_encoded (l_author.name)) end if attached a_node.modification_date as l_modified then s.append (" (modified: ") @@ -321,9 +322,9 @@ feature -- Output -- if attached a_node.summary as l_summary then -- s.append ("

") -- if attached node_api.cms_api.format (a_node.format) as f then --- s.append (f.formatted_output (l_summary)) +-- append_formatted_output (l_content, f, s) -- else --- s.append (a_response.formats.default_format.formatted_output (l_summary)) +-- append_formatted_output (l_content, a_response.formats.default_format, s) -- end -- s.append ("

") @@ -333,9 +334,9 @@ feature -- Output if attached a_node.content as l_content then s.append ("

") if attached node_api.cms_api.format (a_node.format) as f then - s.append (f.formatted_output (l_content)) + append_formatted_output (l_content, f, s) else - s.append (a_response.formats.default_format.formatted_output (l_content)) + append_formatted_output (l_content, a_response.formats.default_format, s) end s.append ("

") @@ -346,5 +347,15 @@ feature -- Output a_response.set_main_content (s) end + append_formatted_output (a_content: READABLE_STRING_GENERAL; a_format: CONTENT_FORMAT; a_output: STRING_8) + -- Format `a_content' with format `a_format'. + do + if a_content.is_valid_as_string_8 then + a_output.append (a_format.formatted_output (a_content.to_string_8)) + else + a_format.append_formatted_to (a_content, a_output) + end + end + end diff --git a/modules/node/persistence/cms_node_storage_sql.e b/modules/node/persistence/cms_node_storage_sql.e index 80dcde3..2be4789 100644 --- a/modules/node/persistence/cms_node_storage_sql.e +++ b/modules/node/persistence/cms_node_storage_sql.e @@ -575,7 +575,7 @@ feature {NONE} -- Implementation if attached sql_read_string_32 (5) as l_summary then Result.set_summary (l_summary) end - if attached sql_read_string (6) as l_content then + if attached sql_read_string_32 (6) as l_content then Result.set_content (l_content) end if attached sql_read_string (7) as l_format then diff --git a/src/persistence/sql/cms_storage_sql_i.e b/src/persistence/sql/cms_storage_sql_i.e index 8b2acef..8798e22 100644 --- a/src/persistence/sql/cms_storage_sql_i.e +++ b/src/persistence/sql/cms_storage_sql_i.e @@ -315,11 +315,14 @@ feature -- Access -- Retrieved value at `a_index' position in `item'. local l_item: like sql_item + utf: UTF_CONVERTER do -- FIXME: handle string_32 ! l_item := sql_item (a_index) if attached {READABLE_STRING_32} l_item as l_string then Result := l_string + elseif attached {READABLE_STRING_8} l_item as l_string_8 then + Result := utf.utf_8_string_8_to_string_32 (l_string_8) else if attached sql_read_string (a_index) as s8 then Result := s8.to_string_32 -- FIXME: any escape?