Decode entities in the title
They will get reencoded (if necessary) when they are output. Fixes #764.
This commit is contained in:
parent
2ec712d6ea
commit
aa00e6b81e
2 changed files with 9 additions and 1 deletions
|
@ -1,7 +1,11 @@
|
|||
require 'htmlentities'
|
||||
|
||||
module TitleHelper
|
||||
@@coder = HTMLEntities.new
|
||||
|
||||
def set_title(title = false)
|
||||
if title
|
||||
@title = title.gsub("<bdi>", "\u202a").gsub("</bdi>", "\u202c")
|
||||
@title = @@coder.decode(title.gsub("<bdi>", "\u202a").gsub("</bdi>", "\u202c"))
|
||||
response.headers["X-Page-Title"] = t('layouts.project_name.title') + ' | ' + @title
|
||||
else
|
||||
@title = title
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue