From 9ff2c2706ffff91de1e03d1d3b2c8d101d33bd6b Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:11:02 +0100 Subject: [PATCH] Sanitise without needing html safe --- app/helpers/application_helper.rb | 6 ++++++ app/helpers/title_helper.rb | 1 + 2 files changed, 7 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 01f7734c2..286409759 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -31,6 +31,12 @@ module ApplicationHelper !current_page?(notifications_path) && (authenticated_user_has_notifications? || unauthenticated_user_has_notifications?) end + def sanitise_characters(string) + return string unless string + + string.gsub("'", "’").gsub("&", "and") + end + private def paginated_title(title, pagy) diff --git a/app/helpers/title_helper.rb b/app/helpers/title_helper.rb index 25dcbc30c..a3512e554 100644 --- a/app/helpers/title_helper.rb +++ b/app/helpers/title_helper.rb @@ -4,6 +4,7 @@ module TitleHelper end def format_title(searched, page_title, current_user, item_label, count, organisation_name) + organisation_name = sanitise_characters(organisation_name) if searched.present? actual_title = support_sab_nav?(current_user, organisation_name) ? organisation_name : page_title "#{actual_title} (#{count} #{item_label} matching ‘#{searched}’)"