From aa00e6b81e007a44eceb8d1a1d70b9b99ec4bc3a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 18 Jun 2014 09:25:01 +0100 Subject: [PATCH 1/1] Decode entities in the title They will get reencoded (if necessary) when they are output. Fixes #764. --- app/helpers/title_helper.rb | 6 +++++- test/helpers/title_helper_test.rb | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/helpers/title_helper.rb b/app/helpers/title_helper.rb index 8cacdf208..a1a2125a1 100644 --- a/app/helpers/title_helper.rb +++ b/app/helpers/title_helper.rb @@ -1,7 +1,11 @@ +require 'htmlentities' + module TitleHelper + @@coder = HTMLEntities.new + def set_title(title = false) if title - @title = title.gsub("", "\u202a").gsub("", "\u202c") + @title = @@coder.decode(title.gsub("", "\u202a").gsub("", "\u202c")) response.headers["X-Page-Title"] = t('layouts.project_name.title') + ' | ' + @title else @title = title diff --git a/test/helpers/title_helper_test.rb b/test/helpers/title_helper_test.rb index cf7a11243..11578cc11 100644 --- a/test/helpers/title_helper_test.rb +++ b/test/helpers/title_helper_test.rb @@ -9,5 +9,9 @@ class TitleHelperTest < ActionView::TestCase set_title("Test Title") assert_equal "OpenStreetMap | Test Title", response.header["X-Page-Title"] assert_equal "Test Title", @title + + set_title("Test & Title") + assert_equal "OpenStreetMap | Test & Title", response.header["X-Page-Title"] + assert_equal "Test & Title", @title end end -- 2.43.2