Browse Source

Sanitise all titles

pull/2643/head
Manny Dinssa 2 years ago
parent
commit
e396a7b19c
  1. 4
      app/helpers/application_helper.rb

4
app/helpers/application_helper.rb

@ -2,6 +2,7 @@ module ApplicationHelper
include Pagy::Frontend include Pagy::Frontend
def browser_title(title, pagy, *resources) def browser_title(title, pagy, *resources)
title = sanitise_characters(title)
if resources.any? { |r| r.present? && r.errors.present? } if resources.any? { |r| r.present? && r.errors.present? }
"Error: #{[title, t('service_name'), 'GOV.UK'].select(&:present?).join(' - ')}" "Error: #{[title, t('service_name'), 'GOV.UK'].select(&:present?).join(' - ')}"
else else
@ -34,7 +35,8 @@ module ApplicationHelper
def sanitise_characters(string) def sanitise_characters(string)
return string unless string return string unless string
string.gsub(/[^a-zA-Z0-9\s\-_'&]/, "").tr("'", "").tr("&", "") CGI.unescapeHTML(string)
# string.gsub(/[^a-zA-Z0-9\s\-_'&]/, "").tr("'", "’").tr("&", "&")
end end
private private

Loading…
Cancel
Save