From 7782ed73b6aa5f4c2da98bff738c957f0dd906bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 5 Oct 2019 23:28:27 +0200 Subject: [PATCH 1/4] Remove unneeded `_html` suffix Although this translation has HTML, we aren't marking them as HTML safe since we're using `I18n.t` instead of Rails' helper `t` method. So using the `_html` suffix is counterintuitive in this case. --- config/locales/en/pages.yml | 2 +- config/locales/es/pages.yml | 2 +- db/pages/accessibility.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/en/pages.yml b/config/locales/en/pages.yml index abe473675..a3a2a3adf 100644 --- a/config/locales/en/pages.yml +++ b/config/locales/en/pages.yml @@ -139,7 +139,7 @@ en: description_column: Decreases text size compatibility: title: Compatibility with standards and visual design - description_html: 'All pages of this website comply with the Accessibility Guidelines or General Principles of Accessible Design established by the Working Group WAI belonging to W3C.' + description: 'All pages of this website comply with the Accessibility Guidelines or General Principles of Accessible Design established by the Working Group WAI belonging to W3C.' titles: help: "What is %{org}? - Citizen participation" verify: diff --git a/config/locales/es/pages.yml b/config/locales/es/pages.yml index 333366f65..9d6c6f1d7 100644 --- a/config/locales/es/pages.yml +++ b/config/locales/es/pages.yml @@ -157,7 +157,7 @@ es: description_column: para reducir el tamaño del texto compatibility: title: Compatibilidad con estándares y diseño visual - description_html: 'Todas las páginas de este sitio web cumplen con las Pautas de Accesibilidad o Principios Generales de Diseño Accesible establecidas por el Grupo de Trabajo WAI perteneciente al W3C.' + description: 'Todas las páginas de este sitio web cumplen con las Pautas de Accesibilidad o Principios Generales de Diseño Accesible establecidas por el Grupo de Trabajo WAI perteneciente al W3C.' titles: help: "¿Qué es %{org}? - Participación ciudadana" verify: diff --git a/db/pages/accessibility.rb b/db/pages/accessibility.rb index 853ec75d7..5741a57cc 100644 --- a/db/pages/accessibility.rb +++ b/db/pages/accessibility.rb @@ -89,7 +89,7 @@ if SiteCustomization::Page.find_by_slug("accessibility").nil? end content << "

#{I18n.t("pages.accessibility.compatibility.title")}

-

#{I18n.t("pages.accessibility.compatibility.description_html")}

" +

#{I18n.t("pages.accessibility.compatibility.description")}

" page.content = content page.save! From b66859945e99addb072fede66230a853b295f8a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 5 Oct 2019 23:34:26 +0200 Subject: [PATCH 2/4] Remove `_html` suffix from already sanitized texts Using the `_html` suffix automatically marks texts as HTML safe, so doing so on sanitized texts is redundant. Note flash texts are not sanitized the moment they are generated, but are sanitized when displayed in the view. --- app/controllers/follows_controller.rb | 4 ++-- app/models/budget/investment.rb | 12 ++++++------ app/views/mailer/budget_investment_created.html.erb | 2 +- .../document_verifications/invalid_document.html.erb | 2 +- app/views/pages/help/_debates.html.erb | 2 +- app/views/proposal_notifications/new.html.erb | 2 +- .../budget_investments/_dossier_form.html.erb | 2 +- config/locales/en/budgets.yml | 4 ++-- config/locales/en/general.yml | 10 +++++----- config/locales/en/mailers.yml | 2 +- config/locales/en/management.yml | 2 +- config/locales/en/pages.yml | 2 +- config/locales/en/valuation.yml | 2 +- config/locales/es/general.yml | 10 +++++----- config/locales/es/mailers.yml | 2 +- config/locales/es/management.yml | 2 +- config/locales/es/pages.yml | 2 +- config/locales/es/valuation.yml | 2 +- spec/models/budget/investment_spec.rb | 4 ++-- 19 files changed, 35 insertions(+), 35 deletions(-) diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 4331a52eb..08753024f 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -4,14 +4,14 @@ class FollowsController < ApplicationController def create @follow = Follow.create(user: current_user, followable: find_followable) - flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow.followable)}.create.notice_html") + flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow.followable)}.create.notice") render :refresh_follow_button end def destroy @follow = Follow.find(params[:id]) @follow.destroy - flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow.followable)}.destroy.notice_html") + flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow.followable)}.destroy.notice") render :refresh_follow_button end diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 5456636d6..5b73520fa 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -267,12 +267,12 @@ class Budget end def reason_for_not_being_ballotable_by(user, ballot) - return permission_problem(user) if permission_problem?(user) - return :not_selected unless selected? - return :no_ballots_allowed unless budget.balloting? - return :different_heading_assigned_html unless ballot.valid_heading?(heading) - return :not_enough_money_html if ballot.present? && !enough_money?(ballot) - return :casted_offline if ballot.casted_offline? + return permission_problem(user) if permission_problem?(user) + return :not_selected unless selected? + return :no_ballots_allowed unless budget.balloting? + return :different_heading_assigned unless ballot.valid_heading?(heading) + return :not_enough_money if ballot.present? && !enough_money?(ballot) + return :casted_offline if ballot.casted_offline? end def permission_problem(user) diff --git a/app/views/mailer/budget_investment_created.html.erb b/app/views/mailer/budget_investment_created.html.erb index 2ba7ef5c1..c7a866112 100644 --- a/app/views/mailer/budget_investment_created.html.erb +++ b/app/views/mailer/budget_investment_created.html.erb @@ -16,7 +16,7 @@

- <%= sanitize(t("mailers.budget_investment_created.follow_html", + <%= sanitize(t("mailers.budget_investment_created.follow", link: link_to(t("mailers.budget_investment_created.follow_link"), budgets_url))) %>

diff --git a/app/views/management/document_verifications/invalid_document.html.erb b/app/views/management/document_verifications/invalid_document.html.erb index 2f7101ca0..936e946c6 100644 --- a/app/views/management/document_verifications/invalid_document.html.erb +++ b/app/views/management/document_verifications/invalid_document.html.erb @@ -11,6 +11,6 @@ permissions: [:debates, :create_proposals] %>

- <%= sanitize(t("management.document_verifications.has_no_account_html", + <%= sanitize(t("management.document_verifications.has_no_account", link: link_to(t("management.document_verifications.link"), root_path, target: "_blank"))) %>

diff --git a/app/views/pages/help/_debates.html.erb b/app/views/pages/help/_debates.html.erb index bc6a3d6d4..c90a58038 100644 --- a/app/views/pages/help/_debates.html.erb +++ b/app/views/pages/help/_debates.html.erb @@ -11,7 +11,7 @@