Skip to content

Commit

Permalink
Merge pull request #934 from alphagov/govspeak-html-safe
Browse files Browse the repository at this point in the history
Only pass in safe HTML to govspeak component
  • Loading branch information
tijmenb authored Jun 11, 2018
2 parents 9496ce1 + 5e763a3 commit c77525e
Show file tree
Hide file tree
Showing 24 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion app/presenters/content_item/body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def body

def govspeak_body
{
content: body,
content: body.html_safe,
direction: text_direction
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/_body_with_related_links.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="grid-row responsive-bottom-margin">
<div class="column-two-thirds">
<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.body,
content: raw(@content_item.body),
direction: page_text_direction,
disable_youtube_expansions: true,
rich_govspeak: true %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/_document_collection_body.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<%= @content_item.group_heading(group) %>
<% if group["body"].present? %>
<%= render 'govuk_publishing_components/components/govspeak',
content: group["body"],
content: raw(group["body"]),
direction: page_text_direction %>
<% end %>

Expand Down
4 changes: 2 additions & 2 deletions app/views/content_items/_publication_inline_body.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div aria-labelledby="documents-title">
<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.documents,
content: @content_item.documents.html_safe,
direction: page_text_direction %>
</div>

Expand All @@ -16,6 +16,6 @@

<div aria-labelledby="details-title">
<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.details,
content: @content_item.details.html_safe,
direction: page_text_direction %>
</div>
2 changes: 1 addition & 1 deletion app/views/content_items/case_study.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
caption: @content_item.image["caption"] if @content_item.image %>

<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.body,
content: @content_item.body.html_safe,
direction: page_text_direction %>
</div>

Expand Down
10 changes: 5 additions & 5 deletions app/views/content_items/consultation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
<%= render 'govuk_publishing_components/components/heading', text: "Download the full outcome", mobile_top_margin: true %>
<div class="consultation-outcome">
<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.final_outcome_documents,
content: @content_item.final_outcome_documents.html_safe,
direction: page_text_direction %>
</div>
<% end %>

<%= render 'govuk_publishing_components/components/heading', text: "Detail of outcome", mobile_top_margin: true %>
<div class="consultation-outcome-detail">
<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.final_outcome_detail,
content: @content_item.final_outcome_detail.html_safe,
direction: page_text_direction %>
</div>
<% end %>
Expand All @@ -57,7 +57,7 @@
<%= render 'govuk_publishing_components/components/heading', text: "Feedback received", mobile_top_margin: true %>
<div class="consultation-feedback-documents">
<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.public_feedback_documents,
content: @content_item.public_feedback_documents.html_safe,
direction: page_text_direction %>
</div >
<% end %>
Expand All @@ -66,7 +66,7 @@
<%= render 'govuk_publishing_components/components/heading', text: "Detail of feedback received", mobile_top_margin: true %>
<div class="consultation-feedback">
<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.public_feedback_detail,
content: @content_item.public_feedback_detail.html_safe,
direction: page_text_direction %>
</div>
<% end %>
Expand Down Expand Up @@ -115,7 +115,7 @@
<%= render 'govuk_publishing_components/components/heading', text: "Documents", mobile_top_margin: true %>
<div class="consultation-documents">
<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.documents,
content: @content_item.documents.html_safe,
direction: page_text_direction %>
</div>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<div class="column-two-thirds">
<%= render "components/contents-list-with-body", contents: @content_item.contents do %>
<div class="responsive-bottom-margin">
<%= render 'govuk_publishing_components/components/govspeak', content: "#{@content_item.body}#{@additional_body}" %>
<%= render 'govuk_publishing_components/components/govspeak', content: "#{@content_item.body}#{@additional_body}".html_safe %>
</div>
<% end %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/fatality_notice.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
alt: @content_item.image["alt_text"],
caption: @content_item.image["caption"] if @content_item.image %>
<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.body,
content: @content_item.body.html_safe,
direction: page_text_direction %>
</div>

Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/gone.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
The information on this page has been removed because it was published in error.
</p>

<%= render 'govuk_publishing_components/components/govspeak', content: @content_item.explanation %>
<%= render 'govuk_publishing_components/components/govspeak', content: @content_item.explanation.html_safe %>

<% if @content_item.alternative_path.present? %>
<p class="alternative">
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/guide.html+print.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<%= "#{index + 1}. #{part['title']}" %>
</h1>
<%= render 'govuk_publishing_components/components/govspeak',
content: part['body'],
content: part['body'].html_safe,
direction: page_text_direction,
disable_youtube_expansions: true,
rich_govspeak: true %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/guide.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</h1>
<% end %>
<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.current_part_body,
content: @content_item.current_part_body.html_safe,
direction: page_text_direction,
disable_youtube_expansions: true,
rich_govspeak: true %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/news_article.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
alt: @content_item.image["alt_text"],
caption: @content_item.image["caption"] if @content_item.image %>
<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.body,
content: @content_item.body.html_safe,
direction: page_text_direction %>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<%= render "govuk_publishing_components/components/fieldset", legend_text: legend_text do %>
<div class="grid-row">
<div class="column-two-thirds">
<%= render 'govuk_publishing_components/components/govspeak', content: @content_item.description %>
<%= render 'govuk_publishing_components/components/govspeak', content: raw(@content_item.description) %>
<% if @error %>
<%= render "components/error-message", text: t('service_sign_in.error.option') %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<div class="grid-row">
<div class="column-two-thirds">
<%= render 'govuk_publishing_components/components/title', title: @content_item.title %>
<%= render 'govuk_publishing_components/components/govspeak', content: @content_item.body %>
<%= render 'govuk_publishing_components/components/govspeak', content: @content_item.body.html_safe %>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/content_items/speech.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
caption: @content_item.image["caption"] if @content_item.image %>

<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.body,
content: @content_item.body.html_safe,
direction: page_text_direction %>
</div>

Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/statistical_data_set.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<%= render "components/contents-list-with-body", contents: @content_item.contents do %>
<div class="responsive-bottom-margin">
<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.body,
content: @content_item.body.html_safe,
direction: page_text_direction %>
</div>
<div class="responsive-bottom-margin">
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/take_part.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
caption: @content_item.image["caption"] if @content_item.image %>

<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.body,
content: @content_item.body.html_safe,
direction: page_text_direction %>
</div>
<%= render 'shared/sidebar_navigation' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/topical_event_about_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
contents: @content_item.contents,
} do %>
<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.body,
content: @content_item.body.html_safe,
direction: page_text_direction %>
<% end %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/travel_advice.html+print.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<%= render 'shared/travel_advice_summary', content_item: @content_item if i == 0 %>

<%= render 'govuk_publishing_components/components/govspeak',
content: part['body'],
content: part['body'].html_safe,
direction: page_text_direction %>
</section>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/travel_advice.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<% end %>

<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.current_part_body,
content: @content_item.current_part_body.html_safe,
direction: page_text_direction %>

<%= render 'govuk_publishing_components/components/previous_and_next_navigation', @content_item.previous_and_next_navigation %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/unpublishing.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
The information on this page has been removed because it was published in error.
</p>

<%= render 'govuk_publishing_components/components/govspeak', content: @content_item.explanation %>
<%= render 'govuk_publishing_components/components/govspeak', content: @content_item.explanation.html_safe %>

<% if @content_item.alternative_url.present? %>
<p class="alternative">
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/working_group.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<%= render 'govuk_publishing_components/components/lead_paragraph', text: @content_item.description %>
<%= render 'components/contents-list-with-body', contents: @content_item.contents do %>
<%= render 'govuk_publishing_components/components/govspeak',
content: "#{@content_item.body} #{@additional_body}",
content: "#{@content_item.body} #{@additional_body}".html_safe,
direction: page_text_direction %>
<% end %>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
caption: @content_item.image["caption"] if @content_item.image %>

<%= render 'govuk_publishing_components/components/govspeak',
content: @content_item.body,
content: @content_item.body.html_safe,
direction: page_text_direction %>
</div>

Expand Down
2 changes: 2 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def setup_and_visit_random_content_item(document_type: nil)
stub_request(:get, %r{#{path}})
.to_return(status: 200, body: content_item.to_json, headers: {})
visit path

assert_equal 200, page.status_code
end

def get_content_example(name)
Expand Down

0 comments on commit c77525e

Please sign in to comment.