")
diff --git a/modules/admin/handler/user/cms_user_form_response.e b/modules/admin/handler/user/cms_admin_user_form_response.e
similarity index 98%
rename from modules/admin/handler/user/cms_user_form_response.e
rename to modules/admin/handler/user/cms_admin_user_form_response.e
index 8bda43d..4da8244 100644
--- a/modules/admin/handler/user/cms_user_form_response.e
+++ b/modules/admin/handler/user/cms_admin_user_form_response.e
@@ -1,10 +1,10 @@
note
- description: "Summary description for {CMS_USER_FORM_RESPONSE}."
+ description: "Summary description for {CMS_ADMIN_USER_FORM_RESPONSE}."
date: "$Date$"
revision: "$Revision$"
class
- CMS_USER_FORM_RESPONSE
+ CMS_ADMIN_USER_FORM_RESPONSE
inherit
CMS_RESPONSE
@@ -324,10 +324,10 @@ feature -- Form
create fs.make
fs.set_legend ("Basic User Account Information")
fs.extend_html_text ("
")
- fs.extend_html_text (a_user.name)
+ fs.extend_raw_text (a_user.name)
if attached a_user.email as l_email then
- create fe.make_with_text ("email", l_email)
+ create fe.make_with_text ("email", l_email.to_string_32)
else
create fe.make_with_text ("email", "")
end
@@ -477,7 +477,7 @@ feature -- Form
api.user_api.user_by_email (l_email) = Void
then
-- Valid email
- a_user.set_email (l_email)
+ a_user.set_email (api.utf_8_encoded (l_email))
else
if attached l_user.email as u_email and then not u_email.is_case_insensitive_equal_general (l_email) then
a_form_data.report_invalid_field ("email", "Email already exist!")
diff --git a/modules/admin/handler/user/cms_user_handler.e b/modules/admin/handler/user/cms_admin_user_handler.e
similarity index 89%
rename from modules/admin/handler/user/cms_user_handler.e
rename to modules/admin/handler/user/cms_admin_user_handler.e
index 5f01136..2f2d427 100644
--- a/modules/admin/handler/user/cms_user_handler.e
+++ b/modules/admin/handler/user/cms_admin_user_handler.e
@@ -1,12 +1,12 @@
note
description: "[
- Handler for a CMS user in the CMS interface
+ Administration handler for a CMS user in the CMS interface
]"
date: "$Date$"
revision: "$Revision$"
class
- CMS_USER_HANDLER
+ CMS_ADMIN_USER_HANDLER
inherit
CMS_HANDLER
@@ -79,12 +79,10 @@ feature -- HTTP Methods
local
l_user: detachable CMS_USER
l_uid: INTEGER_64
- edit_response: CMS_USER_FORM_RESPONSE
- view_response: CMS_USER_VIEW_RESPONSE
- r: CMS_RESPONSE
+ edit_response: CMS_ADMIN_USER_FORM_RESPONSE
+ view_response: CMS_ADMIN_USER_VIEW_RESPONSE
do
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
- if r.has_permission ("admin users") then
+ if api.has_permission ("admin users") then
if req.percent_encoded_path_info.ends_with_general ("/edit") then
check valid_url: req.percent_encoded_path_info.starts_with_general (api.administration_path ("/user/")) end
create edit_response.make (req, res, api)
@@ -111,18 +109,16 @@ feature -- HTTP Methods
end
end
else
- r.execute
+ send_access_denied (req, res)
end
end
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
local
- edit_response: CMS_USER_FORM_RESPONSE
- r: CMS_RESPONSE
+ edit_response: CMS_ADMIN_USER_FORM_RESPONSE
do
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
- if r.has_permission ("admin users") then
+ if api.has_permission ("admin users") then
if req.percent_encoded_path_info.ends_with_general ("/edit") then
create edit_response.make (req, res, api)
edit_response.execute
@@ -138,7 +134,7 @@ feature -- HTTP Methods
edit_response.execute
end
else
- r.execute
+ send_access_denied (req, res)
end
end
@@ -190,7 +186,7 @@ feature {NONE} -- New User
create_new_user (req: WSF_REQUEST; res: WSF_RESPONSE)
local
- edit_response: CMS_USER_FORM_RESPONSE
+ edit_response: CMS_ADMIN_USER_FORM_RESPONSE
do
if req.percent_encoded_path_info.starts_with (api.administration_path ("/add/user")) then
create edit_response.make (req, res, api)
diff --git a/modules/admin/handler/user/cms_user_view_response.e b/modules/admin/handler/user/cms_admin_user_view_response.e
similarity index 97%
rename from modules/admin/handler/user/cms_user_view_response.e
rename to modules/admin/handler/user/cms_admin_user_view_response.e
index 00fccc6..07d17e0 100644
--- a/modules/admin/handler/user/cms_user_view_response.e
+++ b/modules/admin/handler/user/cms_admin_user_view_response.e
@@ -1,10 +1,10 @@
note
- description: "Summary description for {CMS_USER_VIEW_RESPONSE}."
+ description: "Summary description for {CMS_ADMIN_USER_VIEW_RESPONSE}."
date: "$Date$"
revision: "$Revision$"
class
- CMS_USER_VIEW_RESPONSE
+ CMS_ADMIN_USER_VIEW_RESPONSE
inherit
CMS_RESPONSE
@@ -27,7 +27,6 @@ feature -- Query
end
end
-
feature -- Execution
process
diff --git a/modules/admin/handler/user/cms_admin_users_handler.e b/modules/admin/handler/user/cms_admin_users_handler.e
index 735fdd4..8451b2c 100644
--- a/modules/admin/handler/user/cms_admin_users_handler.e
+++ b/modules/admin/handler/user/cms_admin_users_handler.e
@@ -73,8 +73,7 @@ feature -- HTTP Methods
-- get them from the configuration file and load them into
-- the setup class.
- create {FORBIDDEN_ERROR_CMS_RESPONSE} l_response.make (req, res, api)
- if l_response.has_permission ("admin users") then
+ if api.has_permission ("admin users") then
user_api := api.user_api
l_count := user_api.users_count
@@ -157,7 +156,7 @@ feature -- HTTP Methods
l_response.set_main_content (s)
l_response.execute
else
- l_response.execute
+ send_access_denied (req, res)
end
end
end
diff --git a/modules/auth/cms_authentication_email_service.e b/modules/auth/cms_authentication_email_service.e
index f29d80c..57268fb 100644
--- a/modules/auth/cms_authentication_email_service.e
+++ b/modules/auth/cms_authentication_email_service.e
@@ -81,7 +81,7 @@ feature -- Basic Operations / Internal
feature -- Basic Operations / Contact
- send_account_evaluation (a_user: CMS_USER; a_application, a_url_activate, a_url_reject, a_host: READABLE_STRING_8)
+ send_account_evaluation (a_user: CMS_USER; a_application: READABLE_STRING_GENERAL; a_url_activate, a_url_reject, a_host: READABLE_STRING_8)
-- Send new user register to webmaster to confirm or reject itt.
local
l_message: STRING
@@ -95,7 +95,7 @@ feature -- Basic Operations / Contact
else
l_message.replace_substring_all ("$email", "unknown email")
end
- l_message.replace_substring_all ("$application", a_application)
+ l_message.replace_substring_all ("$application", cms_api.utf_8_encoded (a_application))
l_message.replace_substring_all ("$activation_url", a_url_activate)
l_message.replace_substring_all ("$rejection_url", a_url_reject)
send_message (contact_email_address, contact_email_address, parameters.contact_subject_account_evaluation, l_message)
diff --git a/modules/auth/cms_authentication_email_service_parameters.e b/modules/auth/cms_authentication_email_service_parameters.e
index 161761b..d496927 100644
--- a/modules/auth/cms_authentication_email_service_parameters.e
+++ b/modules/auth/cms_authentication_email_service_parameters.e
@@ -13,7 +13,6 @@ feature {NONE} -- Initialization
make (a_cms_api: CMS_API)
local
- utf: UTF_CONVERTER
s: detachable READABLE_STRING_32
l_utf8_site_name: IMMUTABLE_STRING_8
l_contact_email, l_subject_register, l_subject_activate, l_subject_password, l_subject_oauth: detachable READABLE_STRING_8
@@ -31,23 +30,23 @@ feature {NONE} -- Initialization
if attached a_cms_api.module_configuration_by_name ({CMS_AUTHENTICATION_MODULE}.name, Void) as cfg then
s := cfg.text_item ("email")
if s /= Void then
- l_contact_email := utf.utf_32_string_to_utf_8_string_8 (s)
+ l_contact_email := cms_api.utf_8_encoded (s)
end
s := cfg.text_item ("subject_register")
if s /= Void then
- l_subject_register := utf.utf_32_string_to_utf_8_string_8 (s)
+ l_subject_register := cms_api.utf_8_encoded (s)
end
s := cfg.text_item ("subject_activate")
if s /= Void then
- l_subject_register := utf.utf_32_string_to_utf_8_string_8 (s)
+ l_subject_register := cms_api.utf_8_encoded (s)
end
s := cfg.text_item ("subject_password")
if s /= Void then
- l_subject_register := utf.utf_32_string_to_utf_8_string_8 (s)
+ l_subject_register := cms_api.utf_8_encoded (s)
end
s := cfg.text_item ("subject_oauth")
if s /= Void then
- l_subject_oauth := utf.utf_32_string_to_utf_8_string_8 (s)
+ l_subject_oauth := cms_api.utf_8_encoded (s)
end
end
if l_contact_email = Void then
diff --git a/modules/auth/cms_authentication_module.e b/modules/auth/cms_authentication_module.e
index 83311aa..c1e3cdf 100644
--- a/modules/auth/cms_authentication_module.e
+++ b/modules/auth/cms_authentication_module.e
@@ -65,6 +65,7 @@ feature -- Access
Result.force ("account reject")
Result.force ("account reactivate")
Result.force ("change own username")
+ Result.force ("view user")
end
feature {CMS_EXECUTION} -- Administration
@@ -123,6 +124,8 @@ feature -- Router
a_router.handle ("/account/new-password", create {WSF_URI_AGENT_HANDLER}.make (agent handle_new_password(a_api, ?, ?)), a_router.methods_get_post)
a_router.handle ("/account/reset-password", create {WSF_URI_AGENT_HANDLER}.make (agent handle_reset_password(a_api, ?, ?)), a_router.methods_get_post)
a_router.handle ("/account/change/{field}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_change_field (a_api, ?, ?)), a_router.methods_get_post)
+
+ a_router.handle ("/user/{uid}", create {CMS_USER_HANDLER}.make (a_api), a_router.methods_get)
end
feature -- Hooks configuration
@@ -382,7 +385,7 @@ feature -- Handler
l_exist := True
end
if attached recaptcha_secret_key (api) as l_recaptcha_key then
- if attached {WSF_STRING} req.form_parameter ("g-recaptcha-response") as l_recaptcha_response and then is_captcha_verified (l_recaptcha_key, l_recaptcha_response.value) then
+ if attached {WSF_STRING} req.form_parameter ("g-recaptcha-response") as l_recaptcha_response and then is_captcha_verified (l_recaptcha_key, l_recaptcha_response.url_encoded_value) then
l_captcha_passed := True
else
--| Bad or missing captcha
@@ -428,15 +431,13 @@ feature -- Handler
r.set_status_code ({HTTP_CONSTANTS}.bad_request)
end
else
- create {BAD_REQUEST_ERROR_CMS_RESPONSE} r.make (req, res, api)
- r.set_main_content ("There were issue with your application, invalid or missing values.")
+ api.response_api.send_bad_request ("There were issue with your application, invalid or missing values.", req, res)
end
end
+ r.execute
else
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
- r.set_main_content ("You can also contact the webmaster to ask for an account.")
+ api.response_api.send_permissions_access_denied ("You can also contact the webmaster to ask for an account.", Void, req, res)
end
- r.execute
end
handle_activation (api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -500,8 +501,7 @@ feature -- Handler
l_ir.execute
end
else
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
- r.execute
+ api.response_api.send_access_denied (Void, req, res)
end
end
@@ -536,8 +536,7 @@ feature -- Handler
l_ir.execute
end
else
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
- r.execute
+ api.response_api.send_access_denied (Void, req, res)
end
end
@@ -551,8 +550,8 @@ feature -- Handler
l_url_reject: STRING
l_email: READABLE_STRING_8
do
- create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
- if r.has_permission ("account reactivate") then
+ if api.has_permission ("account reactivate") then
+ create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
if req.is_post_request_method then
if attached {WSF_STRING} req.form_parameter ("email") as p_email then
if p_email.value.is_valid_as_string_8 then
@@ -587,11 +586,10 @@ feature -- Handler
end
end
end
- else
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
r.execute
+ else
+ api.response_api.send_access_denied (Void, req, res)
end
- r.execute
end
handle_new_password (api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -700,7 +698,7 @@ feature -- Handler
l_fieldname := p_field.url_encoded_value
end
if l_fieldname = Void then
- create {BAD_REQUEST_ERROR_CMS_RESPONSE} r.make (req, res, api)
+ api.response_api.send_bad_request (Void, req, res)
else
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
@@ -814,8 +812,8 @@ feature -- Handler
end
r.set_main_content (b)
end
+ r.execute
end
- r.execute
end
block_list: ITERABLE [like {CMS_BLOCK}.name]
@@ -1118,36 +1116,30 @@ feature -- Access: configuration
form_registration_application_description (api: CMS_API): detachable READABLE_STRING_8
-- Get recaptcha security key.
- local
- utf: UTF_CONVERTER
do
if attached api.module_configuration (Current, Void) as cfg then
if attached cfg.text_item ("forms.registration.application_description") as l_desc and then not l_desc.is_whitespace then
- Result := utf.utf_32_string_to_utf_8_string_8 (l_desc)
+ Result := api.utf_8_encoded (l_desc)
end
end
end
recaptcha_secret_key (api: CMS_API): detachable READABLE_STRING_8
-- Get recaptcha security key.
- local
- utf: UTF_CONVERTER
do
if attached api.module_configuration (Current, Void) as cfg then
if attached cfg.text_item ("recaptcha.secret_key") as l_recaptcha_key and then not l_recaptcha_key.is_empty then
- Result := utf.utf_32_string_to_utf_8_string_8 (l_recaptcha_key)
+ Result := api.utf_8_encoded (l_recaptcha_key)
end
end
end
recaptcha_site_key (api: CMS_API): detachable READABLE_STRING_8
-- Get recaptcha security key.
- local
- utf: UTF_CONVERTER
do
if attached api.module_configuration (Current, Void) as cfg then
if attached cfg.text_item ("recaptcha.site_key") as l_recaptcha_key and then not l_recaptcha_key.is_empty then
- Result := utf.utf_32_string_to_utf_8_string_8 (l_recaptcha_key)
+ Result := api.utf_8_encoded (l_recaptcha_key)
end
end
end
diff --git a/modules/auth/cms_authentication_module_administration.e b/modules/auth/cms_authentication_module_administration.e
index e8a984d..9fe173c 100644
--- a/modules/auth/cms_authentication_module_administration.e
+++ b/modules/auth/cms_authentication_module_administration.e
@@ -54,9 +54,8 @@ feature -- Request handling
-- get them from the configuration file and load them into
-- the setup class.
- create {FORBIDDEN_ERROR_CMS_RESPONSE} l_response.make (req, res, api)
if
- l_response.has_permission ("admin registration")
+ api.has_permission ("admin registration")
then
l_user_api := api.user_api
@@ -127,7 +126,7 @@ feature -- Request handling
l_response.set_main_content (s)
l_response.execute
else
- l_response.execute
+ api.response_api.send_access_denied (Void, req, res)
end
end
diff --git a/modules/auth/cms_user_handler.e b/modules/auth/cms_user_handler.e
new file mode 100644
index 0000000..d54b431
--- /dev/null
+++ b/modules/auth/cms_user_handler.e
@@ -0,0 +1,103 @@
+note
+ description: "[
+ Handler for a CMS user in the CMS interface
+ ]"
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ CMS_USER_HANDLER
+
+inherit
+ CMS_HANDLER
+
+ WSF_URI_HANDLER
+ rename
+ execute as uri_execute,
+ new_mapping as new_uri_mapping
+ end
+
+ WSF_URI_TEMPLATE_HANDLER
+ rename
+ execute as uri_template_execute,
+ new_mapping as new_uri_template_mapping
+ select
+ new_uri_template_mapping
+ end
+
+ WSF_RESOURCE_HANDLER_HELPER
+ redefine
+ do_get
+ end
+
+ REFACTORING_HELPER
+
+create
+ make
+
+feature -- execute
+
+ execute (req: WSF_REQUEST; res: WSF_RESPONSE)
+ -- Execute request handler
+ do
+ execute_methods (req, res)
+ end
+
+ uri_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
+ -- Execute request handler
+ do
+ execute (req, res)
+ end
+
+ uri_template_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
+ -- Execute request handler
+ do
+ execute (req, res)
+ end
+
+feature -- Query
+
+ user_id_path_parameter (req: WSF_REQUEST): INTEGER_64
+ -- User id passed as path parameter for request `req'.
+ local
+ s: STRING
+ do
+ if attached {WSF_STRING} req.path_parameter ("uid") as p_nid then
+ s := p_nid.value
+ if s.is_integer_64 then
+ Result := s.to_integer_64
+ end
+ end
+ end
+
+feature -- HTTP Methods
+
+ do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
+ --
+ local
+ l_user: detachable CMS_USER
+ l_uid: INTEGER_64
+ view_response: CMS_USER_VIEW_RESPONSE
+ do
+ if api.has_permission ("view user") then
+ -- Display existing node
+ l_uid := user_id_path_parameter (req)
+ if l_uid > 0 then
+ l_user := api.user_api.user_by_id (l_uid)
+ if
+ l_user /= Void
+ then
+ create view_response.make (req, res, api)
+ view_response.execute
+ else
+ send_not_found (req, res)
+ end
+ else
+ send_bad_request (req, res)
+ end
+ else
+ send_access_denied (req, res)
+ end
+ end
+
+end
diff --git a/modules/auth/cms_user_view_response.e b/modules/auth/cms_user_view_response.e
new file mode 100644
index 0000000..612180c
--- /dev/null
+++ b/modules/auth/cms_user_view_response.e
@@ -0,0 +1,103 @@
+note
+ description: "Summary description for {CMS_USER_VIEW_RESPONSE}."
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ CMS_USER_VIEW_RESPONSE
+
+inherit
+ CMS_RESPONSE
+
+create
+ make
+
+feature -- Query
+
+ user_id_path_parameter (req: WSF_REQUEST): INTEGER_64
+ -- User id passed as path parameter for request `req'.
+ local
+ s: STRING
+ do
+ if attached {WSF_STRING} req.path_parameter ("uid") as p_nid then
+ s := p_nid.value
+ if s.is_integer_64 then
+ Result := s.to_integer_64
+ end
+ end
+ end
+
+feature -- Process
+
+ process
+ -- Computed response message.
+ local
+ b: STRING_8
+ uid: INTEGER_64
+ user_api: CMS_USER_API
+ f: CMS_FORM
+ do
+ user_api := api.user_api
+ create b.make_empty
+ uid := user_id_path_parameter (request)
+ if
+ uid > 0 and then
+ attached user_api.user_by_id (uid) as l_user
+ then
+ if
+ api.has_permission ("view user")
+ or l_user.same_as (user) -- Same user
+ then
+ f := new_view_form (l_user, request.request_uri, "view-user")
+ f.append_to_html (wsf_theme, b)
+ else
+ b.append ("You don't have the permission to view this user!")
+ end
+ else
+ b.append ("User not found!")
+ end
+ set_main_content (b)
+ end
+
+feature -- Process Edit
+
+ new_view_form (a_user: detachable CMS_USER; a_url: READABLE_STRING_8; a_name: STRING): CMS_FORM
+ -- Create a web form named `a_name' for user `a_user' (if set), using form action url `a_url'.
+ local
+ th: WSF_FORM_HIDDEN_INPUT
+ do
+ create Result.make (a_url, a_name)
+
+ create th.make ("user-id")
+ if a_user /= Void then
+ th.set_text_value (a_user.id.out)
+ else
+ th.set_text_value ("0")
+ end
+ Result.extend (th)
+
+ populate_form (Result, a_user)
+ end
+
+ populate_form (a_form: WSF_FORM; a_user: detachable CMS_USER)
+ -- Fill the web form `a_form' with data from `a_node' if set,
+ -- and apply this to content type `a_content_type'.
+ local
+ ti: WSF_FORM_TEXT_INPUT
+ fs: WSF_FORM_FIELD_SET
+ do
+ if a_user /= Void then
+ create fs.make
+ fs.set_legend ("User Information")
+ create ti.make_with_text ("profile_name", a_user.name)
+ if attached a_user.profile_name as l_profile_name then
+ ti.set_text_value (l_profile_name)
+ end
+ ti.set_label ("Profile name")
+ ti.set_is_readonly (True)
+ fs.extend (ti)
+ a_form.extend (fs)
+ end
+ end
+
+end
diff --git a/modules/blog/handler/blog_user_handler.e b/modules/blog/handler/blog_user_handler.e
index 674788c..d471921 100644
--- a/modules/blog/handler/blog_user_handler.e
+++ b/modules/blog/handler/blog_user_handler.e
@@ -37,8 +37,6 @@ feature -- HTTP Methods
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
--
- local
- l_error: NOT_FOUND_ERROR_CMS_RESPONSE
do
check user_void: user = Void end
if attached user_from_request (req) as l_user then
@@ -47,13 +45,11 @@ feature -- HTTP Methods
Precursor (req, res)
else
-- Throw a bad request error because the user is not valid
- create l_error.make (req, res, api)
if attached user_parameter (req) as l_user_id then
- l_error.set_main_content ("
Error
User with id " + api.html_encoded (l_user_id) + " not found!")
+ api.response_api.send_not_found ("
Error
User with id " + api.html_encoded (l_user_id) + " not found!", req, res)
else
- l_error.set_main_content ("
Error
User not found!")
+ api.response_api.send_not_found ("
Error
User not found!", req, res)
end
- l_error.execute
end
user := Void
end
diff --git a/modules/contact/src/cms_contact_module.e b/modules/contact/src/cms_contact_module.e
index 6db9fa3..d7da476 100644
--- a/modules/contact/src/cms_contact_module.e
+++ b/modules/contact/src/cms_contact_module.e
@@ -123,30 +123,26 @@ feature -- Recaptcha
recaptcha_secret_key (api: CMS_API): detachable READABLE_STRING_8
-- Get recaptcha security key.
- local
- utf: UTF_CONVERTER
do
if attached api.module_configuration (Current, Void) as cfg then
if
attached cfg.text_item ("recaptcha.secret_key") as l_recaptcha_key and then
not l_recaptcha_key.is_empty
then
- Result := utf.utf_32_string_to_utf_8_string_8 (l_recaptcha_key)
+ Result := api.utf_8_encoded (l_recaptcha_key)
end
end
end
recaptcha_site_key (api: CMS_API): detachable READABLE_STRING_8
-- Get recaptcha security key.
- local
- utf: UTF_CONVERTER
do
if attached api.module_configuration (Current, Void) as cfg then
if
attached cfg.text_item ("recaptcha.site_key") as l_recaptcha_key and then
not l_recaptcha_key.is_empty
then
- Result := utf.utf_32_string_to_utf_8_string_8 (l_recaptcha_key)
+ Result := api.utf_8_encoded (l_recaptcha_key)
end
end
end
diff --git a/modules/contact/src/contact_email_service_parameters.e b/modules/contact/src/contact_email_service_parameters.e
index 4baedbe..6aa0ef4 100644
--- a/modules/contact/src/contact_email_service_parameters.e
+++ b/modules/contact/src/contact_email_service_parameters.e
@@ -13,13 +13,12 @@ feature {NONE} -- Initialization
make (a_cms_api: CMS_API; a_contact_module: CMS_CONTACT_MODULE)
local
- utf: UTF_CONVERTER
l_site_name: READABLE_STRING_8
s: detachable READABLE_STRING_32
l_contact_email, l_contact_subject: detachable READABLE_STRING_8
do
-- Use global smtp setting if any, otherwise "localhost"
- l_site_name := utf.escaped_utf_32_string_to_utf_8_string_8 (a_cms_api.setup.site_name)
+ l_site_name := a_cms_api.utf_8_encoded (a_cms_api.setup.site_name)
admin_email := a_cms_api.setup.site_email
if not admin_email.has ('<') then
@@ -29,11 +28,11 @@ feature {NONE} -- Initialization
if attached {CONFIG_READER} a_cms_api.module_configuration (a_contact_module, Void) as cfg then
s := cfg.text_item ("email")
if s /= Void then
- l_contact_email := utf.utf_32_string_to_utf_8_string_8 (s)
+ l_contact_email := a_cms_api.utf_8_encoded (s)
end
s := cfg.text_item ("subject")
if s /= Void then
- l_contact_subject := utf.utf_32_string_to_utf_8_string_8 (s)
+ l_contact_subject := a_cms_api.utf_8_encoded (s)
end
end
if l_contact_email /= Void then
diff --git a/modules/contact/src/persistence/contact_storage_fs.e b/modules/contact/src/persistence/contact_storage_fs.e
index fa6a921..5af97d5 100644
--- a/modules/contact/src/persistence/contact_storage_fs.e
+++ b/modules/contact/src/persistence/contact_storage_fs.e
@@ -25,7 +25,6 @@ feature -- Change
save_contact_message (m: CONTACT_MESSAGE)
local
s: STRING
- utf: UTF_CONVERTER
now: DATE_TIME
do
error_handler.reset
@@ -38,7 +37,7 @@ feature -- Change
s.append (m.date.out)
s.append_character ('%N')
s.append ("name=")
- s.append (utf.utf_32_string_to_utf_8_string_8 (m.username))
+ s.append (api.utf_8_encoded (m.username))
s.append_character ('%N')
if attached m.email as l_email then
@@ -47,7 +46,7 @@ feature -- Change
s.append_character ('%N')
end
s.append ("message=%N")
- s.append (utf.utf_32_string_to_utf_8_string_8 (m.message))
+ s.append (api.utf_8_encoded (m.message))
s.append_character ('%N')
save_to_file (s, date_to_yyyymmdd_hhmmss_string (now))
diff --git a/modules/embedded_video/src/video_content_filter.e b/modules/embedded_video/src/video_content_filter.e
index 3a28e8d..f1f5f18 100644
--- a/modules/embedded_video/src/video_content_filter.e
+++ b/modules/embedded_video/src/video_content_filter.e
@@ -253,11 +253,19 @@ feature {NONE} -- Implementation
end
replace_substring_all (s: STRING_GENERAL; a_old: READABLE_STRING_8; a_new: STRING_GENERAL)
+ local
+ utf: UTF_CONVERTER
do
if attached {STRING_8} s as s8 then
- s8.replace_substring_all (a_old, a_new.to_string_8)
+ if a_new.is_valid_as_string_8 then
+ s8.replace_substring_all (a_old, a_new.to_string_8)
+ else
+ check a_new_is_string_8: False end
+ -- Use UTF-8 for now.
+ s8.replace_substring_all (a_old, utf.utf_32_string_to_utf_8_string_8 (a_new))
+ end
elseif attached {STRING_32} s as s32 then
- s32.replace_substring_all (a_old, a_new)
+ s32.replace_substring_all (a_old.to_string_32, a_new)
end
end
diff --git a/modules/feed_aggregator/feed_aggregator_api.e b/modules/feed_aggregator/feed_aggregator_api.e
index 0cffb44..1c35d43 100644
--- a/modules/feed_aggregator/feed_aggregator_api.e
+++ b/modules/feed_aggregator/feed_aggregator_api.e
@@ -35,7 +35,6 @@ feature -- Access
l_feed_id: READABLE_STRING_32
l_title: detachable READABLE_STRING_GENERAL
l_locations: detachable STRING_TABLE [READABLE_STRING_8]
- utf: UTF_CONVERTER
l_table: like internal_aggregations
do
l_table := internal_aggregations
@@ -56,20 +55,20 @@ feature -- Access
across
l_location_list as loc_ic
loop
- l_locations.force (utf.utf_32_string_to_utf_8_string_8 (loc_ic.item), loc_ic.item)
+ l_locations.force (cms_api.utf_8_encoded (loc_ic.item), loc_ic.item)
end
end
if attached cfg.text_table_item ({STRING_32} "feeds." + l_feed_id + ".locations") as l_location_table then
across
l_location_table as loc_tb_ic
loop
- l_locations.force (utf.utf_32_string_to_utf_8_string_8 (loc_tb_ic.item), loc_tb_ic.key)
+ l_locations.force (cms_api.utf_8_encoded (loc_tb_ic.item), loc_tb_ic.key)
end
end
if
attached cfg.text_item ({STRING_32} "feeds." + l_feed_id + ".location") as l_location
then
- l_locations.force (utf.utf_32_string_to_utf_8_string_8 (l_location), l_location)
+ l_locations.force (cms_api.utf_8_encoded (l_location), l_location)
end
if l_locations /= Void and then not l_locations.is_empty then
l_title := cfg.text_item ({STRING_32} "feeds." + l_feed_id + ".title")
@@ -93,7 +92,7 @@ feature -- Access
across
l_locations as loc_ic
loop
- agg.locations.force (utf.utf_32_string_to_utf_8_string_8 (loc_ic.item))
+ agg.locations.force (cms_api.utf_8_encoded (loc_ic.item))
end
Result.force (agg, l_feed_id)
if attached cfg.text_list_item ({STRING_32} "feeds." + l_feed_id + ".categories") as l_cats then
diff --git a/modules/feed_aggregator/feed_aggregator_module.e b/modules/feed_aggregator/feed_aggregator_module.e
index 60a335a..a843146 100644
--- a/modules/feed_aggregator/feed_aggregator_module.e
+++ b/modules/feed_aggregator/feed_aggregator_module.e
@@ -98,8 +98,7 @@ feature -- Handle
m.header.put_content_type_text_html
res.send (m)
else
- create {NOT_FOUND_ERROR_CMS_RESPONSE} r.make (req, res, a_api)
- r.execute
+ a_api.response_api.send_not_found (Void, req, res)
end
else
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, a_api)
@@ -143,8 +142,7 @@ feature -- Handle
r.execute
end
else
- create {NOT_FOUND_ERROR_CMS_RESPONSE} r.make (req, res, a_api)
- r.execute
+ a_api.response_api.send_not_found (Void, req, res)
end
else
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, a_api)
@@ -199,7 +197,6 @@ feature -- Hook
-- List of block names, managed by current object.
local
res: ARRAYED_LIST [like {CMS_BLOCK}.name]
- utf_conv: UTF_CONVERTER
do
if
attached feed_aggregator_api as l_feed_api and then
@@ -209,7 +206,7 @@ feature -- Hook
across
l_aggs as ic
loop
- res.force ("?feed." + utf_conv.utf_32_string_to_utf_8_string_8 (ic.item))
+ res.force ("?feed." + utf_8_encoded (ic.item))
end
else
create res.make (0)
diff --git a/modules/files/cms_files_module.e b/modules/files/cms_files_module.e
index 98df481..129ce7d 100644
--- a/modules/files/cms_files_module.e
+++ b/modules/files/cms_files_module.e
@@ -140,8 +140,8 @@ feature -- Handler
do
check req.is_get_request_method end
if not api.has_permission (browse_files_permission) then
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
- r.add_error_message ("You are not allowed to browse CMS files!")
+ create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make_with_permissions (req, res, api, <>)
+ r.add_error_message ("You are not allowed to browse files!")
elseif attached {WSF_STRING} req.path_parameter ("filename") as p_filename then
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
@@ -276,7 +276,7 @@ feature -- Handler
body.append ("%N")
- body.append ("Use basic file uploading.%N")
+ body.append ("Use basic file uploading.%N")
end
body.append ("
")
end
@@ -284,15 +284,15 @@ feature -- Handler
if req.is_get_head_request_method then
-- Build the response.
if r.has_permission (browse_files_permission) then
- body.append ("
")
append_uploaded_file_album_to (req, api, body)
else
r.add_warning_message ("You are not allowed to browse files!")
end
end
-
r.set_main_content (body)
+ r.execute
elseif req.is_post_request_method then
if api.has_permission (upload_files_permission) then
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
@@ -305,14 +305,13 @@ feature -- Handler
r.set_redirection (r.url (uploads_location, Void))
end
r.set_main_content (body)
+ r.execute
else
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
- r.set_main_content ("You are not allowed to upload file!")
+ api.response_api.send_permissions_access_denied ("You are not allowed to upload file!", <>, req, res)
end
else
- create {BAD_REQUEST_ERROR_CMS_RESPONSE} r.make (req, res, api)
+ api.response_api.send_bad_request (Void, req, res)
end
- r.execute
end
process_uploaded_files (req: WSF_REQUEST; api: CMS_API; a_output: STRING)
@@ -472,7 +471,7 @@ feature -- Handler
do
if attached files_api as l_files_api then
if not api.has_permission (admin_files_permission) then
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
+ create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make_with_permissions (req, res, api, <>)
r.add_error_message ("You are not allowed to remove file!")
elseif attached {WSF_STRING} req.path_parameter ("filename") as p_filename then
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
diff --git a/modules/files/cms_uploaded_file.e b/modules/files/cms_uploaded_file.e
index ccc77ab..48a1e8c 100644
--- a/modules/files/cms_uploaded_file.e
+++ b/modules/files/cms_uploaded_file.e
@@ -83,14 +83,16 @@ feature -- Element change
-- sets `a_number' after the name. This is done when the file was already uploaded
local
position: INTEGER_32
- new_name: STRING_8
+ new_name: STRING_32
+ l_uploaded_file_string_representation: READABLE_STRING_32
do
- position := uploaded_file.string_representation.index_of ('.', 1)
+ l_uploaded_file_string_representation := uploaded_file.string_representation
+ position := l_uploaded_file_string_representation.index_of ('.', 1)
create new_name.make_empty
- new_name := uploaded_file.string_representation.head (position-1)
- new_name.append ("_(" + a_number.out + ")")
- new_name.append (uploaded_file.string_representation.substring (position, uploaded_file.string_representation.count))
+ new_name := l_uploaded_file_string_representation.head (position-1)
+ new_name.append_string_general ("_(" + a_number.out + ")")
+ new_name.append (l_uploaded_file_string_representation.substring (position, l_uploaded_file_string_representation.count))
location := uploads_directory.extended (new_name)
end
diff --git a/modules/google_search_20/src/google_custom_search_module_20.e b/modules/google_search_20/src/google_custom_search_module_20.e
index cfa2e8a..9a9f38b 100644
--- a/modules/google_search_20/src/google_custom_search_module_20.e
+++ b/modules/google_search_20/src/google_custom_search_module_20.e
@@ -57,15 +57,13 @@ feature -- GCSE Keys
gcse_cx_key (api: CMS_API): detachable READABLE_STRING_8
-- Get google custom search engine id.
- local
- utf: UTF_CONVERTER
do
if attached api.module_configuration (Current, Void) as cfg then
if
attached cfg.text_item ("gcse.search_engine_id") as l_gcse_cx_key and then
not l_gcse_cx_key.is_empty
then
- Result := utf.utf_32_string_to_utf_8_string_8 (l_gcse_cx_key)
+ Result := api.utf_8_encoded (l_gcse_cx_key)
end
end
end
diff --git a/modules/messaging/src/cms_messaging_module.e b/modules/messaging/src/cms_messaging_module.e
index b0f589d..da5f855 100644
--- a/modules/messaging/src/cms_messaging_module.e
+++ b/modules/messaging/src/cms_messaging_module.e
@@ -223,12 +223,12 @@ $(document).ready(function() {
local
r: CMS_RESPONSE
do
- if api.has_permission ("use messaging") or api.has_permission ("message any user") then
+ if api.has_permissions (<<"use messaging", "message any user">>) then
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
r.values.force ("messaging", "messaging")
r.set_main_content (new_html_messaging_form (r, api))
else
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
+ create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make_with_permissions (req, res, api, <<"use messaging", "message any user">>)
end
r.execute
end
@@ -314,7 +314,7 @@ $(document).ready(function() {
end
r.set_main_content (s)
else
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
+ create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make_with_permissions (req, res, api, <<"message any user">>)
end
r.execute
end
@@ -337,9 +337,8 @@ feature {NONE} -- Contact Message
resolved_template_text (api: CMS_API; a_text: READABLE_STRING_GENERAL; a_target_user: detachable CMS_USER): STRING_8
local
smt: CMS_SMARTY_TEMPLATE_TEXT
- utf: UTF_CONVERTER
do
- create smt.make (utf.utf_32_string_to_utf_8_string_8 (a_text))
+ create smt.make (api.utf_8_encoded (a_text))
across
api.builtin_variables as vars_ic
loop
diff --git a/modules/node/cms_node_module.e b/modules/node/cms_node_module.e
index a0d2ba7..3484cb2 100644
--- a/modules/node/cms_node_module.e
+++ b/modules/node/cms_node_module.e
@@ -372,7 +372,7 @@ feature -- Hooks
loop
if
attached ic.item.typename as l_typename and then
- across l_node_typenames as t_ic some t_ic.item.same_string (l_typename) end
+ across l_node_typenames as t_ic some t_ic.item.same_string_general (l_typename) end
then
if ic.item.entity.is_integer then
nid := ic.item.entity.to_integer_64
diff --git a/modules/node/handler/cms_node_type_webform_manager.e b/modules/node/handler/cms_node_type_webform_manager.e
index 27398e1..cfd22a4 100644
--- a/modules/node/handler/cms_node_type_webform_manager.e
+++ b/modules/node/handler/cms_node_type_webform_manager.e
@@ -142,8 +142,8 @@ feature -- Forms ...
ti.set_description ("Optionally specify an alternative URL path by which this content can be accessed. %NFor example, type 'about' when writing an about page. Use a relative path or the URL alias won't work.")
end
- ti.set_text_value (l_uri)
- ti.set_placeholder (l_auto_path_alias)
+ ti.set_text_value (l_uri.to_string_32)
+ ti.set_placeholder (l_auto_path_alias.to_string_32)
ti.set_validation_action (agent (fd: WSF_FORM_DATA; ia_response: NODE_RESPONSE; ia_node: detachable CMS_NODE)
do
if
@@ -204,7 +204,7 @@ feature -- Forms ...
end
-- Auto path alias / suggestion
create thi.make ("auto_path_alias")
- thi.set_text_value (l_auto_path_alias)
+ thi.set_text_value (l_auto_path_alias.to_string_32)
thi.set_is_readonly (True)
f.insert_before (thi, w)
end
diff --git a/modules/node/handler/node_form_response.e b/modules/node/handler/node_form_response.e
index 331da77..e4da68e 100644
--- a/modules/node/handler/node_form_response.e
+++ b/modules/node/handler/node_form_response.e
@@ -241,7 +241,11 @@ feature -- Form
if attached fd.string_item ("content") as l_content then
b.append ("Content:
")
if l_format /= Void then
- b.append (l_format.formatted_output (l_content))
+ if l_content.is_valid_as_string_8 then
+ b.append (l_format.formatted_output (l_content.to_string_8))
+ else
+ b.append (l_format.formatted_output (api.utf_8_encoded (l_content)))
+ end
else
b.append (html_encoded (l_content))
end
diff --git a/modules/node/handler/node_handler.e b/modules/node/handler/node_handler.e
index 47ebd16..6b0cf4b 100644
--- a/modules/node/handler/node_handler.e
+++ b/modules/node/handler/node_handler.e
@@ -75,6 +75,14 @@ feature -- Query
end
end
+feature -- Permissions
+
+ view_unpublished_permissions (a_node: CMS_NODE): ITERABLE [READABLE_STRING_8]
+ -- Permissions to view unpublished node `a_node`.
+ do
+ Result := <<"view unpublished " + a_node.content_type>>
+ end
+
feature -- HTTP Methods
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -148,7 +156,7 @@ feature -- HTTP Methods
attached api.user as l_user and then
( node_api.is_author_of_node (l_user, l_node)
or else (
- api.user_has_permission (l_user, "view unpublished " + l_node.content_type)
+ api.user_has_permissions (l_user, view_unpublished_permissions (l_node))
)
)
then
@@ -403,15 +411,10 @@ feature -- Error
send_access_denied_to_unpublished_node (req: WSF_REQUEST; res: WSF_RESPONSE; a_node: CMS_NODE)
-- Forbidden response.
- local
- r: CMS_RESPONSE
do
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
- r.set_main_content ("This content is NOT published!")
- r.execute
+ send_custom_access_denied ("This content is NOT published!", view_unpublished_permissions (a_node), req, res)
end
-
feature {NONE} -- Node
create_new_node (req: WSF_REQUEST; res: WSF_RESPONSE)
diff --git a/modules/node/handler/trash_handler.e b/modules/node/handler/trash_handler.e
index e032d3a..9df0e29 100644
--- a/modules/node/handler/trash_handler.e
+++ b/modules/node/handler/trash_handler.e
@@ -86,8 +86,7 @@ feature -- HTTP Methods
-- l_page.add_block (create {CMS_CONTENT_BLOCK}.make ("nodes_warning", Void, "/nodes/ is not yet fully implemented ", Void), "highlighted")
l_page.execute
else
- create {FORBIDDEN_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
- l_page.execute
+ send_custom_access_denied (Void, <<"view trash", "view any trash", "view own trash">>, req, res)
end
end
diff --git a/modules/openid/cms_openid_api.e b/modules/openid/cms_openid_api.e
index d0543fd..0023b6b 100644
--- a/modules/openid/cms_openid_api.e
+++ b/modules/openid/cms_openid_api.e
@@ -79,7 +79,7 @@ feature -- Access: Consumers OAuth20
Result := openid_storage.openid_consumers
end
- openid_consumer_by_name (a_name: READABLE_STRING_8): detachable CMS_OPENID_CONSUMER
+ openid_consumer_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_OPENID_CONSUMER
-- Retrieve a consumer by name `a_name', if any.
do
Result := openid_storage.openid_consumer_by_name (a_name)
diff --git a/modules/openid/cms_openid_module.e b/modules/openid/cms_openid_module.e
index 211607a..05cba2b 100644
--- a/modules/openid/cms_openid_module.e
+++ b/modules/openid/cms_openid_module.e
@@ -226,7 +226,7 @@ feature -- Hooks
create o.make (req.absolute_script_url ("/account/auth/login-with-openid"))
o.ask_email (True)
o.ask_all_info (False)
- if attached o.auth_url (p_openid) as l_url then
+ if p_openid.is_valid_as_string_8 and then attached o.auth_url (p_openid.to_string_8) as l_url then
r.set_redirection (l_url)
else
s.append (" Failure")
@@ -248,7 +248,7 @@ feature -- Hooks
attached {WSF_STRING} req.cookie (a_openid_api.session_token) as l_cookie_token
then
-- Logout OAuth
- create l_cookie.make (a_openid_api.session_token, l_cookie_token.value)
+ create l_cookie.make (a_openid_api.session_token, l_cookie_token.url_encoded_value)
l_cookie.set_path ("/")
l_cookie.set_max_age (-1)
res.add_cookie (l_cookie)
@@ -335,6 +335,7 @@ feature -- Openid Login
b: STRING
o: OPENID_CONSUMER
v: OPENID_CONSUMER_VALIDATION
+ l_email: STRING_8
do
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
create b.make_empty
@@ -346,8 +347,9 @@ feature -- Openid Login
v.validate
if v.is_valid then
if attached v.identity as l_identity and then
- attached v.email_attribute as l_email
+ attached v.email_attribute as l_email_attrib
then
+ l_email := api.utf_8_encoded (l_email_attrib)
l_user_api := api.user_api
if attached l_user_api.user_by_email (l_email) as p_user then
-- User with email exist
@@ -355,7 +357,7 @@ feature -- Openid Login
-- Update openid entry?
else
-- create a oauth entry
- a_openid_api.new_user_openid (l_identity,p_user)
+ a_openid_api.new_user_openid (l_identity, p_user)
end
create l_cookie.make (a_openid_api.session_token, l_identity)
l_cookie.set_max_age (a_openid_api.session_max_age)
@@ -368,7 +370,7 @@ feature -- Openid Login
l_roles.force (l_user_api.authenticated_user_role)
-- Create a new user and oauth entry
- create l_user.make (l_email)
+ create l_user.make (l_email_attrib)
l_user.set_email (l_email)
l_user.set_password (new_token) -- generate a random password.
l_user.set_roles (l_roles)
diff --git a/modules/openid/persitence/cms_openid_storage_i.e b/modules/openid/persitence/cms_openid_storage_i.e
index bb0ae47..690e87b 100644
--- a/modules/openid/persitence/cms_openid_storage_i.e
+++ b/modules/openid/persitence/cms_openid_storage_i.e
@@ -37,7 +37,7 @@ feature -- Access: Consumers
deferred
end
- openid_consumer_by_name (a_name: READABLE_STRING_8): detachable CMS_OPENID_CONSUMER
+ openid_consumer_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_OPENID_CONSUMER
-- Retrieve a consumer by name `a_name', if any.
deferred
end
@@ -49,6 +49,6 @@ feature -- Change: User Oauth2
deferred
end
-
+
end
diff --git a/modules/openid/persitence/cms_openid_storage_null.e b/modules/openid/persitence/cms_openid_storage_null.e
index bd552da..b822dba 100644
--- a/modules/openid/persitence/cms_openid_storage_null.e
+++ b/modules/openid/persitence/cms_openid_storage_null.e
@@ -39,7 +39,7 @@ feature -- Access: Consumers
create {ARRAYED_LIST[STRING]}Result.make(0)
end
- openid_consumer_by_name (a_name: READABLE_STRING_8): detachable CMS_OPENID_CONSUMER
+ openid_consumer_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_OPENID_CONSUMER
--
do
end
diff --git a/modules/openid/persitence/cms_openid_storage_sql.e b/modules/openid/persitence/cms_openid_storage_sql.e
index 9239205..268f861 100644
--- a/modules/openid/persitence/cms_openid_storage_sql.e
+++ b/modules/openid/persitence/cms_openid_storage_sql.e
@@ -99,7 +99,7 @@ feature --Access: Consumers
sql_finalize
end
- openid_consumer_by_name (a_name: READABLE_STRING_8): detachable CMS_OPENID_CONSUMER
+ openid_consumer_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_OPENID_CONSUMER
-- Retrieve a consumer by name `a_name', if any.
local
l_parameters: STRING_TABLE [detachable ANY]
diff --git a/modules/recent_changes/cms_recent_changes_module.e b/modules/recent_changes/cms_recent_changes_module.e
index 0bc1a7d..e976dac 100644
--- a/modules/recent_changes/cms_recent_changes_module.e
+++ b/modules/recent_changes/cms_recent_changes_module.e
@@ -141,7 +141,7 @@ feature -- Hook
create s.make_empty
if attached ch.information as l_information then
- s.append (l_information)
+ s.append_string_general (l_information)
end
if attached ch.summary as sum then
if not s.is_empty then
@@ -248,9 +248,9 @@ feature -- Handler
l_size := 25
end
- create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
- if r.has_permission ("view recent changes") then
- l_user := r.user
+ if api.has_permission ("view recent changes") then
+ create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
+ l_user := api.user
create l_changes.make (l_size, l_until_date, l_filter_source)
create l_content.make (1024)
@@ -406,11 +406,10 @@ feature -- Handler
create htdate.make_from_date_time (l_until_date)
r.set_title ("Recent changes before " + htdate.string)
end
+ r.execute
else
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
+ api.response_api.send_permissions_access_denied (Void, <<"view recent changes">>, req, res)
end
-
- r.execute
end
feature -- Hooks configuration
diff --git a/modules/sitemap/cms_sitemap_module.e b/modules/sitemap/cms_sitemap_module.e
index 2d4a3bc..23ad907 100644
--- a/modules/sitemap/cms_sitemap_module.e
+++ b/modules/sitemap/cms_sitemap_module.e
@@ -123,8 +123,7 @@ feature -- Handler
mesg.set_payload (l_sitemap_xml)
res.send (mesg)
else
- create {NOT_FOUND_ERROR_CMS_RESPONSE} r.make (req, res, api)
- r.execute
+ api.response_api.send_not_found (Void, req, res)
end
end
end
diff --git a/modules/taxonomy/handler/taxonomy_handler.e b/modules/taxonomy/handler/taxonomy_handler.e
index 444a1cb..a0e13a3 100644
--- a/modules/taxonomy/handler/taxonomy_handler.e
+++ b/modules/taxonomy/handler/taxonomy_handler.e
@@ -143,11 +143,11 @@ feature -- HTTP Methods
s.append ("No entity found.")
end
l_page.set_main_content (s)
+ l_page.execute
else
-- Responding with `main_content_html (l_page)'.
- create {NOT_FOUND_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
+ send_not_found (req, res)
end
- l_page.execute
else
-- Responding with `main_content_html (l_page)'.
create {BAD_REQUEST_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
diff --git a/modules/taxonomy/handler/taxonomy_vocabulary_admin_handler.e b/modules/taxonomy/handler/taxonomy_vocabulary_admin_handler.e
index 9d9e281..ad765b7 100644
--- a/modules/taxonomy/handler/taxonomy_vocabulary_admin_handler.e
+++ b/modules/taxonomy/handler/taxonomy_vocabulary_admin_handler.e
@@ -277,13 +277,13 @@ feature -- HTTP Methods
l_typename := ic.item.name
create w_cb.make_with_value ("typenames[]", api.html_encoded (l_typename))
- w_cb.set_title (ic.item.name)
+ w_cb.set_title (ic.item.name.to_string_32)
wtb_row.set_item (create {WSF_WIDGET_TABLE_ITEM}.make_with_content (w_cb), 1)
v := Void
if
l_typenames /= Void and then
- across l_typenames as tn_ic some l_typename.is_case_insensitive_equal (tn_ic.item) end
+ across l_typenames as tn_ic some l_typename.is_case_insensitive_equal_general (tn_ic.item) end
then
w_cb.set_checked (True)
if attached taxonomy_api.vocabularies_for_type (l_typename) as v_list then
@@ -319,11 +319,11 @@ feature -- HTTP Methods
create s.make_empty
f.append_to_html (l_page.wsf_theme, s)
l_page.set_main_content (s)
+ l_page.execute
else
-- Responding with `main_content_html (l_page)'.
- create {NOT_FOUND_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
+ send_not_found (req, res)
end
- l_page.execute
end
do_get_vocabularies (req: WSF_REQUEST; res: WSF_RESPONSE)
diff --git a/modules/taxonomy/handler/taxonomy_vocabulary_handler.e b/modules/taxonomy/handler/taxonomy_vocabulary_handler.e
index 6db90f4..41ac365 100644
--- a/modules/taxonomy/handler/taxonomy_vocabulary_handler.e
+++ b/modules/taxonomy/handler/taxonomy_vocabulary_handler.e
@@ -99,11 +99,11 @@ feature -- HTTP Methods
end
s.append ("")
l_page.set_main_content (s)
+ l_page.execute
else
-- Responding with `main_content_html (l_page)'.
- create {NOT_FOUND_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
+ send_not_found (req, res)
end
- l_page.execute
else
-- Responding with `main_content_html (l_page)'.
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
diff --git a/src/configuration/cms_default_setup.e b/src/configuration/cms_default_setup.e
index 3c502ac..8212b53 100644
--- a/src/configuration/cms_default_setup.e
+++ b/src/configuration/cms_default_setup.e
@@ -87,7 +87,7 @@ feature -- Access
do
if attached text_item (a_name) as s then
if s.is_valid_as_string_8 then
- Result := s.as_string_8
+ Result := s.to_string_8
else
Result := utf.escaped_utf_32_string_to_utf_8_string_8 (s)
end
@@ -101,10 +101,11 @@ feature -- Access
l_chain: NOTIFICATION_CHAIN_MAILER
l_storage_mailer: NOTIFICATION_STORAGE_MAILER
l_mailer: detachable NOTIFICATION_MAILER
+ b: BOOLEAN
do
if not retried then
- if attached text_item ("mailer.smtp") as l_smtp then
- create {NOTIFICATION_SMTP_MAILER} l_mailer.make (l_smtp.as_string_8_conversion)
+ if attached text_item ("mailer.smtp") as l_smtp and then l_smtp.is_valid_as_string_8 then
+ create {NOTIFICATION_SMTP_MAILER} l_mailer.make (l_smtp.to_string_8)
elseif attached text_item ("mailer.sendmail") as l_sendmail then
create {NOTIFICATION_SENDMAIL_MAILER} l_mailer.make_with_location (l_sendmail)
end
@@ -120,19 +121,24 @@ feature -- Access
if f.exists and then f.is_directory then
create {NOTIFICATION_STORAGE_MAILER} l_storage_mailer.make (create {NOTIFICATION_EMAIL_DIRECTORY_STORAGE}.make (f.path))
else
- if not f.exists then
- f.create_read_write
- f.close
+ if f.exists then
+ b := True
+ else
+ b := (create {CMS_FILE_SYSTEM_UTILITIES}).safe_create_raw_file (f.path)
+ end
+ if b then
+ create {NOTIFICATION_STORAGE_MAILER} l_storage_mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (f))
end
- create {NOTIFICATION_STORAGE_MAILER} l_storage_mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (f))
end
end
if l_mailer /= Void then
create l_chain.make (l_mailer)
l_chain.set_next (l_storage_mailer)
l_mailer := l_chain
- else
+ elseif l_storage_mailer /= Void then
l_mailer := l_storage_mailer
+ else
+ create {NOTIFICATION_NULL_MAILER} l_mailer
end
elseif l_mailer = Void then
create {NOTIFICATION_STORAGE_MAILER} l_mailer.make (create {NOTIFICATION_EMAIL_FILE_STORAGE}.make (io.error))
diff --git a/src/kernel/content/cms_encoders.e b/src/kernel/content/cms_encoders.e
index 46aedd7..42d4433 100644
--- a/src/kernel/content/cms_encoders.e
+++ b/src/kernel/content/cms_encoders.e
@@ -21,6 +21,14 @@ inherit
feature -- Encoders
+ utf_8_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
+ -- `a_string' encoded using UTF-8.
+ local
+ utf: UTF_CONVERTER
+ do
+ Result := utf.utf_32_string_to_utf_8_string_8 (a_string)
+ end
+
html_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
-- `a_string' encoded for html output.
do
@@ -36,7 +44,7 @@ feature -- Encoders
Result := ""
end
end
-
+
url_encoded,
percent_encoded (a_string: READABLE_STRING_GENERAL): STRING_8
-- `a_string' encoded with percent encoding, mainly used for url.
@@ -45,6 +53,6 @@ feature -- Encoders
end
note
- copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
+ copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end
diff --git a/src/persistence/cms_storage_null.e b/src/persistence/cms_storage_null.e
index 2025986..31ec294 100644
--- a/src/persistence/cms_storage_null.e
+++ b/src/persistence/cms_storage_null.e
@@ -75,7 +75,7 @@ feature -- URL aliases
do
end
- source_of_path_alias (a_alias: READABLE_STRING_8): detachable READABLE_STRING_8
+ source_of_path_alias (a_alias: READABLE_STRING_GENERAL): detachable READABLE_STRING_8
-- Source path for alias `a_alias'.
do
end
@@ -136,6 +136,6 @@ feature -- Custom
end
note
- copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
+ copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end
diff --git a/src/persistence/core/cms_core_storage_i.e b/src/persistence/core/cms_core_storage_i.e
index b285e22..ba2006a 100644
--- a/src/persistence/core/cms_core_storage_i.e
+++ b/src/persistence/core/cms_core_storage_i.e
@@ -42,7 +42,7 @@ feature -- URL aliases
deferred
end
- source_of_path_alias (a_alias: READABLE_STRING_8): detachable READABLE_STRING_8
+ source_of_path_alias (a_alias: READABLE_STRING_GENERAL): detachable READABLE_STRING_8
-- Source path for alias `a_alias'.
deferred
end
@@ -89,6 +89,6 @@ feature -- Misc
end
note
- copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
+ copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end
diff --git a/src/persistence/core/cms_core_storage_sql_i.e b/src/persistence/core/cms_core_storage_sql_i.e
index 7f96523..87474c8 100644
--- a/src/persistence/core/cms_core_storage_sql_i.e
+++ b/src/persistence/core/cms_core_storage_sql_i.e
@@ -123,7 +123,7 @@ feature -- URL aliases
sql_finalize
end
- source_of_path_alias (a_alias: READABLE_STRING_8): detachable READABLE_STRING_8
+ source_of_path_alias (a_alias: READABLE_STRING_GENERAL): detachable READABLE_STRING_8
--
local
l_parameters: STRING_TABLE [detachable ANY]
diff --git a/src/service/cms_api.e b/src/service/cms_api.e
index 78fcc64..4c6b215 100644
--- a/src/service/cms_api.e
+++ b/src/service/cms_api.e
@@ -642,7 +642,7 @@ feature -- Status Report
feature -- Logging
- logs (a_category: detachable READABLE_STRING_8; a_lower: INTEGER; a_count: INTEGER): LIST [CMS_LOG]
+ logs (a_category: detachable READABLE_STRING_GENERAL; a_lower: INTEGER; a_count: INTEGER): LIST [CMS_LOG]
-- List of recent logs from `a_lower' to `a_lower+a_count'.
-- If `a_category' is set, filter to return only associated logs.
-- If `a_count' <= 0 then, return all logs.
@@ -1001,6 +1001,19 @@ feature -- Access: API
Result := l_api
end
+ response_api: CMS_RESPONSE_API
+ -- API to send predefined cms responses.
+ local
+ l_api: like internal_response_api
+ do
+ l_api := internal_response_api
+ if l_api = Void then
+ create l_api.make (Current)
+ internal_response_api := l_api
+ end
+ Result := l_api
+ end
+
feature -- Hooks
setup_core_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
@@ -1014,9 +1027,9 @@ feature -- Hooks
feature -- Path aliases
- is_valid_path_alias (a_alias: READABLE_STRING_8): BOOLEAN
+ is_valid_path_alias (a_alias: READABLE_STRING_GENERAL): BOOLEAN
do
- Result := a_alias.is_empty or else not a_alias.starts_with_general ("/")
+ Result := a_alias.is_empty or else not a_alias.starts_with ("/")
end
set_path_alias (a_source, a_alias: READABLE_STRING_8; a_keep_previous: BOOLEAN)
@@ -1076,7 +1089,7 @@ feature -- Path aliases
end
end
- source_of_path_alias (a_alias: READABLE_STRING_8): detachable READABLE_STRING_8
+ source_of_path_alias (a_alias: READABLE_STRING_GENERAL): detachable READABLE_STRING_8
-- Resolved path for alias `a_alias'.
--| the CMS supports aliases for path, and then this function simply returns
--| the effective target path/url for this `a_alias'.
@@ -1106,6 +1119,9 @@ feature {NONE}-- Implementation
internal_user_api: detachable like user_api
-- Cached value for `user_api`.
+ internal_response_api: detachable like response_api
+ -- Cached value for `response_api`.
+
feature -- Environment/ theme
site_location: PATH
diff --git a/src/service/cms_execution.e b/src/service/cms_execution.e
index bcac24c..0173c5a 100644
--- a/src/service/cms_execution.e
+++ b/src/service/cms_execution.e
@@ -196,24 +196,24 @@ feature -- Settings: router
local
fhdl: WSF_FILE_SYSTEM_HANDLER
themehdl: CMS_THEME_FILE_SYSTEM_HANDLER
+ l_not_found_handler_agent: PROCEDURE [READABLE_STRING_8, WSF_REQUEST, WSF_RESPONSE]
do
api.logger.put_information (generator + ".configure_api_file_handler", Void)
- create themehdl.make (api)
- themehdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
+ l_not_found_handler_agent := agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
do
execute_default (ia_req, ia_res)
- end)
+ end
+
+ create themehdl.make (api)
+ themehdl.set_not_found_handler (l_not_found_handler_agent)
-- See CMS_API.api.theme_path_for (...) for the hardcoded "/theme/" path.
a_router.handle ("/theme/{theme_id}{/vars}", themehdl, router.methods_GET)
-- "/files/.."
create fhdl.make_hidden_with_path (api.files_location)
fhdl.disable_index
- fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
- do
- execute_default (ia_req, ia_res)
- end)
+ fhdl.set_not_found_handler (l_not_found_handler_agent)
a_router.handle (api.files_path, fhdl, router.methods_GET)
-- files folder from specific module.
@@ -222,10 +222,7 @@ feature -- Settings: router
-- www folder. Should we keep this??
create fhdl.make_hidden_with_path (setup.environment.www_path)
fhdl.disable_index
- fhdl.set_not_found_handler (agent (ia_uri: READABLE_STRING_8; ia_req: WSF_REQUEST; ia_res: WSF_RESPONSE)
- do
- execute_default (ia_req, ia_res)
- end)
+ fhdl.set_not_found_handler (l_not_found_handler_agent)
a_router.handle ("/", fhdl, router.methods_GET)
end
@@ -328,7 +325,6 @@ feature -- Execution
local
ut: FILE_UTILITIES
p: PATH
- r: NOT_FOUND_ERROR_CMS_RESPONSE
f: WSF_FILE_RESPONSE
do
p := api.theme_assets_location.extended ("favicon.ico")
@@ -337,8 +333,7 @@ feature -- Execution
f.set_expires_in_seconds (86_400) -- 24h = 60 sec * 60 min * 24 = 86 400 minutes
res.send (f)
else
- create r.make (req, res, api)
- r.execute
+ api.response_api.send_not_found (Void, req, res)
end
end
@@ -347,7 +342,6 @@ feature -- Execution
-- i.e: "/module/{modname}/files{/vars}"
local
fhdl: WSF_FILE_SYSTEM_HANDLER
- r: NOT_FOUND_ERROR_CMS_RESPONSE
do
if attached {WSF_STRING} req.path_parameter ("modname") as l_mod_name then
create fhdl.make_with_path (api.module_location_by_name (l_mod_name.url_encoded_value).extended ("files"))
@@ -358,19 +352,15 @@ feature -- Execution
end)
fhdl.execute_starts_with ("/module/" + l_mod_name.url_encoded_value + "/files/", req, res)
else
- create r.make (req, res, api)
- r.execute
+ api.response_api.send_not_found (Void, req, res)
end
end
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Default request handler if no other are relevant
- local
- r: NOT_FOUND_ERROR_CMS_RESPONSE
do
to_implement ("Default response for CMS_SERVICE")
- create r.make (req, res, api)
- r.execute
+ api.response_api.send_not_found (Void, req, res)
end
note
diff --git a/src/service/cms_file_system_utilities.e b/src/service/cms_file_system_utilities.e
index 5ed222d..87492bf 100644
--- a/src/service/cms_file_system_utilities.e
+++ b/src/service/cms_file_system_utilities.e
@@ -6,7 +6,7 @@ note
class
CMS_FILE_SYSTEM_UTILITIES
-feature -- Files
+feature -- File path
relative_path_inside (a_path: PATH; a_root_path: PATH): detachable PATH
-- Relative path from `a_root_path` to `a_path`, or Void if `a_path` is not inside `a_root_path`.
@@ -43,6 +43,8 @@ feature -- Files
end
end
+feature -- Read
+
files_from_location (a_loc: PATH; is_recursive: BOOLEAN): detachable LIST [PATH]
local
d: DIRECTORY
@@ -82,13 +84,14 @@ feature -- Files
retry
end
+feature -- Read/Write
+
safe_copy_file (src,dst: PATH): BOOLEAN
-- Copy file from `src` to `dst'
-- and return True on success, False on failure.
local
retried: BOOLEAN
f_src, f_dst: RAW_FILE
- d: DIRECTORY
do
Result := False
if retried then
@@ -96,20 +99,45 @@ feature -- Files
else
create f_src.make_with_path (src)
if f_src.exists and then f_src.is_access_readable then
- if attached dst.parent as l_parent then
- create d.make_with_path (l_parent)
- if not d.exists then
- d.recursive_create_dir
+ if safe_create_parent_directory (dst) then
+ create f_dst.make_with_path (dst)
+ if not f_dst.exists or else f_dst.is_access_writable then
+ f_src.open_read
+ f_dst.open_write
+ f_src.copy_to (f_dst)
+ f_dst.close
+ f_src.close
+ Result := True -- Succeed!
end
+ else
+ Result := False -- No parent directory!
end
- create f_dst.make_with_path (dst)
- if not f_dst.exists or else f_dst.is_access_writable then
- f_src.open_read
- f_dst.open_write
- f_src.copy_to (f_dst)
- f_dst.close
- f_src.close
- Result := True -- Succeed!
+ end
+ end
+ rescue
+ retried := True
+ retry
+ end
+
+feature -- Create
+
+ safe_create_raw_file (p: PATH): BOOLEAN
+ -- Create file at `p`
+ -- and return True on success or if file already exists, False on failure.
+ local
+ retried: BOOLEAN
+ f: RAW_FILE
+ do
+ Result := False
+ if not retried then
+ if safe_create_parent_directory (p) then
+ create f.make_with_path (p)
+ if f.exists then
+ Result := True
+ else
+ f.create_read_write
+ f.close
+ Result := f.exists
end
end
end
@@ -118,6 +146,28 @@ feature -- Files
retry
end
+ safe_create_parent_directory (p: PATH): BOOLEAN
+ -- Create parent directory of `p`
+ -- and return True on success or if parent already exists, False on failure.
+ local
+ retried: BOOLEAN
+ d: DIRECTORY
+ do
+ Result := False
+ if not retried then
+ create d.make_with_path (p.parent)
+ if d.exists then
+ Result := True
+ else
+ d.recursive_create_dir
+ Result := d.exists
+ end
+ end
+ rescue
+ retried := True
+ retry
+ end
+
note
copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
diff --git a/src/service/handler/cms_admin_install_handler.e b/src/service/handler/cms_admin_install_handler.e
index 0eaf680..d065c8b 100644
--- a/src/service/handler/cms_admin_install_handler.e
+++ b/src/service/handler/cms_admin_install_handler.e
@@ -45,7 +45,10 @@ feature -- HTTP Methods
lst: ARRAYED_LIST [CMS_MODULE]
l_access: detachable READABLE_STRING_8
l_denied: BOOLEAN
+ l_is_fresh_installation: BOOLEAN
do
+ l_is_fresh_installation := api.enabled_modules.count <= 1 --| Should have at least the required Core module!
+
--| FIXME: improve the installer.
create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api)
l_access := api.setup.string_8_item ("admin.installation_access")
@@ -62,8 +65,7 @@ feature -- HTTP Methods
l_denied := True
end
if l_denied then
- create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
- r.set_main_content ("You do not have permission to access CMS installation procedure!")
+ send_custom_access_denied ("You do not have permission to access CMS installation procedure!", Void, req, res)
else
create s.make_from_string ("