diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4caf0398f..b120615ac 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -79,7 +79,7 @@ module ApplicationHelper def html_title safe_join( - [content_for(:page_title).to_s.chomp, title] + [content_for(:page_title), title] .compact_blank, ' - ' ) diff --git a/app/views/about/show.html.haml b/app/views/about/show.html.haml index 05d8989ad..e8f7b43ea 100644 --- a/app/views/about/show.html.haml +++ b/app/views/about/show.html.haml @@ -1,5 +1,4 @@ -- content_for :page_title do - = t('about.title') +- content_for :page_title, t('about.title') - content_for :header_tags do = render partial: 'shared/og' diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml index dde9c5084..1f5f81348 100644 --- a/app/views/accounts/show.html.haml +++ b/app/views/accounts/show.html.haml @@ -1,5 +1,4 @@ -- content_for :page_title do - #{display_name(@account)} (#{acct(@account)}) +- content_for :page_title, "#{display_name(@account)} (#{acct(@account)})" - content_for :header_tags do - if @account.user_prefers_noindex? diff --git a/app/views/privacy/show.html.haml b/app/views/privacy/show.html.haml index 95e506641..9eb4f7a57 100644 --- a/app/views/privacy/show.html.haml +++ b/app/views/privacy/show.html.haml @@ -1,5 +1,4 @@ -- content_for :page_title do - = t('privacy_policy.title') +- content_for :page_title, t('privacy_policy.title') - content_for :header_tags do = render partial: 'shared/og' diff --git a/app/views/statuses/show.html.haml b/app/views/statuses/show.html.haml index 08bab6307..f669885de 100644 --- a/app/views/statuses/show.html.haml +++ b/app/views/statuses/show.html.haml @@ -1,5 +1,4 @@ -- content_for :page_title do - = t('statuses.title', name: display_name(@account), quote: truncate(@status.spoiler_text.presence || @status.text, length: 50, omission: '…', escape: false)) +- content_for :page_title, t('statuses.title', name: display_name(@account), quote: truncate(@status.spoiler_text.presence || @status.text, length: 50, omission: '…', escape: false)) - content_for :header_tags do - if @account.user_prefers_noindex? diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 0f78dc82f..7a8dd5ebe 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -279,11 +279,11 @@ RSpec.describe ApplicationHelper do expect(helper.html_title).to be_html_safe end - it 'removes extra new lines' do + it 'does not escape twice' do Setting.site_title = 'Site Title' - helper.content_for(:page_title, "Test Value\n") + helper.content_for(:page_title, '"Test Value"'.html_safe) - expect(helper.html_title).to eq 'Test Value - Site Title' + expect(helper.html_title).to eq '"Test Value" - Site Title' expect(helper.html_title).to be_html_safe end end diff --git a/spec/views/statuses/show.html.haml_spec.rb b/spec/views/statuses/show.html.haml_spec.rb index 1afcb046d..02b1fe738 100644 --- a/spec/views/statuses/show.html.haml_spec.rb +++ b/spec/views/statuses/show.html.haml_spec.rb @@ -18,7 +18,7 @@ RSpec.describe 'statuses/show.html.haml' do assign(:descendant_threads, []) end - it 'has valid opengraph tags' do + it 'has valid opengraph tags and twitter player tags' do render expect(header_tags) @@ -26,10 +26,6 @@ RSpec.describe 'statuses/show.html.haml' do .and match(//) .and match(//) .and match(%r{}) - end - - it 'has twitter player tag' do - render expect(header_tags) .to match(%r{})