Fix titles being escaped twice (#32889)
This commit is contained in:
		@@ -79,7 +79,7 @@ module ApplicationHelper
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  def html_title
 | 
					  def html_title
 | 
				
			||||||
    safe_join(
 | 
					    safe_join(
 | 
				
			||||||
      [content_for(:page_title).to_s.chomp, title]
 | 
					      [content_for(:page_title), title]
 | 
				
			||||||
      .compact_blank,
 | 
					      .compact_blank,
 | 
				
			||||||
      ' - '
 | 
					      ' - '
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,4 @@
 | 
				
			|||||||
- content_for :page_title do
 | 
					- content_for :page_title, t('about.title')
 | 
				
			||||||
  = t('about.title')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
- content_for :header_tags do
 | 
					- content_for :header_tags do
 | 
				
			||||||
  = render partial: 'shared/og'
 | 
					  = render partial: 'shared/og'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,4 @@
 | 
				
			|||||||
- content_for :page_title do
 | 
					- content_for :page_title, "#{display_name(@account)} (#{acct(@account)})"
 | 
				
			||||||
  #{display_name(@account)} (#{acct(@account)})
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
- content_for :header_tags do
 | 
					- content_for :header_tags do
 | 
				
			||||||
  - if @account.user_prefers_noindex?
 | 
					  - if @account.user_prefers_noindex?
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,4 @@
 | 
				
			|||||||
- content_for :page_title do
 | 
					- content_for :page_title, t('privacy_policy.title')
 | 
				
			||||||
  = t('privacy_policy.title')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
- content_for :header_tags do
 | 
					- content_for :header_tags do
 | 
				
			||||||
  = render partial: 'shared/og'
 | 
					  = render partial: 'shared/og'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,4 @@
 | 
				
			|||||||
- content_for :page_title do
 | 
					- content_for :page_title, t('statuses.title', name: display_name(@account), quote: truncate(@status.spoiler_text.presence || @status.text, length: 50, omission: '…', escape: false))
 | 
				
			||||||
  = 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
 | 
					- content_for :header_tags do
 | 
				
			||||||
  - if @account.user_prefers_noindex?
 | 
					  - if @account.user_prefers_noindex?
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -257,11 +257,11 @@ RSpec.describe ApplicationHelper do
 | 
				
			|||||||
        expect(helper.html_title).to be_html_safe
 | 
					        expect(helper.html_title).to be_html_safe
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      it 'removes extra new lines' do
 | 
					      it 'does not escape twice' do
 | 
				
			||||||
        Setting.site_title = 'Site Title'
 | 
					        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
 | 
					        expect(helper.html_title).to be_html_safe
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,7 @@ RSpec.describe 'statuses/show.html.haml' do
 | 
				
			|||||||
    assign(:descendant_threads, [])
 | 
					    assign(:descendant_threads, [])
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it 'has valid opengraph tags' do
 | 
					  it 'has valid opengraph tags and twitter player tags' do
 | 
				
			||||||
    render
 | 
					    render
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expect(header_tags)
 | 
					    expect(header_tags)
 | 
				
			||||||
@@ -26,10 +26,6 @@ RSpec.describe 'statuses/show.html.haml' do
 | 
				
			|||||||
      .and match(/<meta content="article" property="og:type">/)
 | 
					      .and match(/<meta content="article" property="og:type">/)
 | 
				
			||||||
      .and match(/<meta content=".+" property="og:image">/)
 | 
					      .and match(/<meta content=".+" property="og:image">/)
 | 
				
			||||||
      .and match(%r{<meta content="http://.+" property="og:url">})
 | 
					      .and match(%r{<meta content="http://.+" property="og:url">})
 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  it 'has twitter player tag' do
 | 
					 | 
				
			||||||
    render
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    expect(header_tags)
 | 
					    expect(header_tags)
 | 
				
			||||||
      .to match(%r{<meta content="http://.+/media/.+/player" property="twitter:player">})
 | 
					      .to match(%r{<meta content="http://.+/media/.+/player" property="twitter:player">})
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user