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.
This commit is contained in:
Javi Martín
2019-10-05 23:34:26 +02:00
parent 7782ed73b6
commit b66859945e
19 changed files with 35 additions and 35 deletions

View File

@@ -4,14 +4,14 @@ class FollowsController < ApplicationController
def create def create
@follow = Follow.create(user: current_user, followable: find_followable) @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 render :refresh_follow_button
end end
def destroy def destroy
@follow = Follow.find(params[:id]) @follow = Follow.find(params[:id])
@follow.destroy @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 render :refresh_follow_button
end end

View File

@@ -267,12 +267,12 @@ class Budget
end end
def reason_for_not_being_ballotable_by(user, ballot) def reason_for_not_being_ballotable_by(user, ballot)
return permission_problem(user) if permission_problem?(user) return permission_problem(user) if permission_problem?(user)
return :not_selected unless selected? return :not_selected unless selected?
return :no_ballots_allowed unless budget.balloting? return :no_ballots_allowed unless budget.balloting?
return :different_heading_assigned_html unless ballot.valid_heading?(heading) return :different_heading_assigned unless ballot.valid_heading?(heading)
return :not_enough_money_html if ballot.present? && !enough_money?(ballot) return :not_enough_money if ballot.present? && !enough_money?(ballot)
return :casted_offline if ballot.casted_offline? return :casted_offline if ballot.casted_offline?
end end
def permission_problem(user) def permission_problem(user)

View File

@@ -16,7 +16,7 @@
</p> </p>
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;"> <p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;">
<%= 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))) %> link: link_to(t("mailers.budget_investment_created.follow_link"), budgets_url))) %>
</p> </p>

View File

@@ -11,6 +11,6 @@
permissions: [:debates, :create_proposals] %> permissions: [:debates, :create_proposals] %>
<p> <p>
<%= 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"))) %> link: link_to(t("management.document_verifications.link"), root_path, target: "_blank"))) %>
</p> </p>

View File

@@ -11,7 +11,7 @@
</p> </p>
<ul class="features"> <ul class="features">
<li> <li>
<%= sanitize(t("pages.help.debates.feature_html", <%= sanitize(t("pages.help.debates.feature",
link: link_to(t("pages.help.debates.feature_link", org: setting["org_name"]), link: link_to(t("pages.help.debates.feature_link", org: setting["org_name"]),
new_user_registration_path))) %> new_user_registration_path))) %>
</li> </li>

View File

@@ -6,7 +6,7 @@
<div class="callout primary"> <div class="callout primary">
<p> <p>
<%= sanitize(t("proposal_notifications.new.info_about_receivers_html", <%= sanitize(t("proposal_notifications.new.info_about_receivers",
count: @proposal.users_to_notify.count, count: @proposal.users_to_notify.count,
proposal_page: link_to(t("proposal_notifications.new.proposal_page"), proposal_page: link_to(t("proposal_notifications.new.proposal_page"),
proposal_path(@proposal, anchor: "comments")))) %> proposal_path(@proposal, anchor: "comments")))) %>

View File

@@ -47,7 +47,7 @@
<div class="small-12 medium-6 column end"> <div class="small-12 medium-6 column end">
<%= f.number_field :price_first_year, <%= f.number_field :price_first_year,
label: t("valuation.budget_investments.edit.price_first_year_html", currency: budget.currency_symbol), label: t("valuation.budget_investments.edit.price_first_year", currency: budget.currency_symbol),
max: 1000000000000000 %> max: 1000000000000000 %>
</div> </div>
</div> </div>

View File

@@ -18,9 +18,9 @@ en:
not_verified: Only verified users can vote on investments; %{verify_account}. not_verified: Only verified users can vote on investments; %{verify_account}.
organization: Organizations are not permitted to vote organization: Organizations are not permitted to vote
not_selected: Unselected investment projects can not be supported not_selected: Unselected investment projects can not be supported
not_enough_money_html: "You have already assigned the available budget.<br><small>Remember you can %{change_ballot} at any time</small>" not_enough_money: "You have already assigned the available budget.<br><small>Remember you can %{change_ballot} at any time</small>"
no_ballots_allowed: Selecting phase is closed no_ballots_allowed: Selecting phase is closed
different_heading_assigned_html: "You have already voted a different heading: %{heading_link}" different_heading_assigned: "You have already voted a different heading: %{heading_link}"
change_ballot: change your votes change_ballot: change your votes
casted_offline: You have already participated offline casted_offline: You have already participated offline
groups: groups:

View File

@@ -693,7 +693,7 @@ en:
new: new:
title: "Send message" title: "Send message"
submit_button: "Send message" submit_button: "Send message"
info_about_receivers_html: "This message will be sent to <strong>%{count} people</strong> and it will be visible in %{proposal_page}.<br> Messages are not sent immediately, users will receive periodically an email with all proposal notifications." info_about_receivers: "This message will be sent to <strong>%{count} people</strong> and it will be visible in %{proposal_page}.<br> Messages are not sent immediately, users will receive periodically an email with all proposal notifications."
proposal_page: "the proposal's page" proposal_page: "the proposal's page"
show: show:
back: "Go back to my content" back: "Go back to my content"
@@ -736,14 +736,14 @@ en:
followable: followable:
budget_investment: budget_investment:
create: create:
notice_html: "You are now following this investment project! <br> We will notify you of changes as they occur so that you are up-to-date." notice: "You are now following this investment project! <br> We will notify you of changes as they occur so that you are up-to-date."
destroy: destroy:
notice_html: "You have stopped following this investment project! <br> You will no longer receive notifications related to this project." notice: "You have stopped following this investment project! <br> You will no longer receive notifications related to this project."
proposal: proposal:
create: create:
notice_html: "Now you are following this citizen proposal! <br> We will notify you of changes as they occur so that you are up-to-date." notice: "Now you are following this citizen proposal! <br> We will notify you of changes as they occur so that you are up-to-date."
destroy: destroy:
notice_html: "You have stopped following this citizen proposal! <br> You will no longer receive notifications related to this proposal." notice: "You have stopped following this citizen proposal! <br> You will no longer receive notifications related to this proposal."
hide: Hide hide: Hide
print: print:
print_button: Print this info print_button: Print this info

View File

@@ -48,7 +48,7 @@ en:
title: "Thank you for creating an investment!" title: "Thank you for creating an investment!"
intro: "Hi <strong>%{author}</strong>," intro: "Hi <strong>%{author}</strong>,"
text: "Thank you for creating your investment <strong>%{investment}</strong> for Participatory Budgets <strong>%{budget}</strong>." text: "Thank you for creating your investment <strong>%{investment}</strong> for Participatory Budgets <strong>%{budget}</strong>."
follow_html: "We will inform you about how the process progresses, which you can also follow on <strong>%{link}</strong>." follow: "We will inform you about how the process progresses, which you can also follow on <strong>%{link}</strong>."
follow_link: "Participatory Budgets" follow_link: "Participatory Budgets"
sincerely: "Sincerely," sincerely: "Sincerely,"
share: "Share your project" share: "Share your project"

View File

@@ -34,7 +34,7 @@ en:
info: Here you can manage users through all actions listed in the left menu. info: Here you can manage users through all actions listed in the left menu.
document_verifications: document_verifications:
already_verified: This user account is already verified. already_verified: This user account is already verified.
has_no_account_html: In order to create an account, go to %{link} and click in <b>"Register"</b> in the upper-left part of the screen. has_no_account: In order to create an account, go to %{link} and click in <b>"Register"</b> in the upper-left part of the screen.
link: CONSUL link: CONSUL
in_census_has_following_permissions: "This user can participate in the website with the following permissions:" in_census_has_following_permissions: "This user can participate in the website with the following permissions:"
not_in_census: This document is not registered. not_in_census: This document is not registered.

View File

@@ -18,7 +18,7 @@ en:
title: "Debates" title: "Debates"
description: "In the %{link} section you can present and share your opinion with other people on issues of concern to you related to the city. It is also a place to generate ideas that through the other sections of %{org} lead to concrete actions by the City Council." description: "In the %{link} section you can present and share your opinion with other people on issues of concern to you related to the city. It is also a place to generate ideas that through the other sections of %{org} lead to concrete actions by the City Council."
link: "citizen debates" link: "citizen debates"
feature_html: "You can open debates, comment and evaluate them with the <strong>I agree</strong> or <strong>I don't agree</strong>. For that you have to %{link}." feature: "You can open debates, comment and evaluate them with the <strong>I agree</strong> or <strong>I don't agree</strong>. For that you have to %{link}."
feature_link: "register in %{org}" feature_link: "register in %{org}"
image_alt: "Buttons to rate the debates" image_alt: "Buttons to rate the debates"
figcaption: '"I agree" and "I disagree" buttons to rate the debates.' figcaption: '"I agree" and "I disagree" buttons to rate the debates.'

View File

@@ -57,7 +57,7 @@ en:
edit: edit:
dossier: Dossier dossier: Dossier
price_html: "Price (%{currency})" price_html: "Price (%{currency})"
price_first_year_html: "Cost during the first year (%{currency}) <small>(optional, data not public)</small>" price_first_year: "Cost during the first year (%{currency}) <small>(optional, data not public)</small>"
feasibility: Feasibility feasibility: Feasibility
valuation_finished_alert: "Are you sure you want to mark this report as completed? If you do it, it can no longer be modified." valuation_finished_alert: "Are you sure you want to mark this report as completed? If you do it, it can no longer be modified."
not_feasible_alert: "An email will be sent immediately to the author of the project with the report of unfeasibility." not_feasible_alert: "An email will be sent immediately to the author of the project with the report of unfeasibility."

View File

@@ -690,7 +690,7 @@ es:
new: new:
title: "Enviar mensaje" title: "Enviar mensaje"
submit_button: "Enviar mensaje" submit_button: "Enviar mensaje"
info_about_receivers_html: "Este mensaje se enviará a <strong>%{count} usuarios</strong> y se publicará en %{proposal_page}.<br> El mensaje no se enviará inmediatamente, los usuarios recibirán periódicamente un email con todas las notificaciones de propuestas." info_about_receivers: "Este mensaje se enviará a <strong>%{count} usuarios</strong> y se publicará en %{proposal_page}.<br> El mensaje no se enviará inmediatamente, los usuarios recibirán periódicamente un email con todas las notificaciones de propuestas."
proposal_page: "la página de la propuesta" proposal_page: "la página de la propuesta"
show: show:
back: "Volver a mi contenido" back: "Volver a mi contenido"
@@ -733,14 +733,14 @@ es:
followable: followable:
budget_investment: budget_investment:
create: create:
notice_html: "¡Ahora estás siguiendo este proyecto de gasto! <br> Te notificaremos los cambios a medida que se produzcan para que estés al día." notice: "¡Ahora estás siguiendo este proyecto de gasto! <br> Te notificaremos los cambios a medida que se produzcan para que estés al día."
destroy: destroy:
notice_html: "¡Has dejado de seguir este proyecto de gasto! <br> Ya no recibirás más notificaciones relacionadas con este proyecto." notice: "¡Has dejado de seguir este proyecto de gasto! <br> Ya no recibirás más notificaciones relacionadas con este proyecto."
proposal: proposal:
create: create:
notice_html: "¡Ahora estás siguiendo esta propuesta ciudadana! <br> Te notificaremos los cambios a medida que se produzcan para que estés al día." notice: "¡Ahora estás siguiendo esta propuesta ciudadana! <br> Te notificaremos los cambios a medida que se produzcan para que estés al día."
destroy: destroy:
notice_html: "¡Has dejado de seguir esta propuesta ciudadana! <br> Ya no recibirás más notificaciones relacionadas con esta propuesta." notice: "¡Has dejado de seguir esta propuesta ciudadana! <br> Ya no recibirás más notificaciones relacionadas con esta propuesta."
hide: Ocultar hide: Ocultar
print: print:
print_button: Imprimir esta información print_button: Imprimir esta información

View File

@@ -48,7 +48,7 @@ es:
title: "¡Gracias por crear un proyecto!" title: "¡Gracias por crear un proyecto!"
intro: "Hola <strong>%{author}</strong>," intro: "Hola <strong>%{author}</strong>,"
text: "Muchas gracias por crear tu proyecto <strong>%{investment}</strong> para los Presupuestos Participativos <strong>%{budget}</strong>." text: "Muchas gracias por crear tu proyecto <strong>%{investment}</strong> para los Presupuestos Participativos <strong>%{budget}</strong>."
follow_html: "Te informaremos de cómo avanza el proceso, que también puedes seguir en la página de <strong>%{link}</strong>." follow: "Te informaremos de cómo avanza el proceso, que también puedes seguir en la página de <strong>%{link}</strong>."
follow_link: "Presupuestos participativos" follow_link: "Presupuestos participativos"
sincerely: "Atentamente," sincerely: "Atentamente,"
share: "Comparte tu proyecto" share: "Comparte tu proyecto"

View File

@@ -34,7 +34,7 @@ es:
info: Desde aquí puedes gestionar usuarios a través de las acciones listadas en el menú de la izquierda. info: Desde aquí puedes gestionar usuarios a través de las acciones listadas en el menú de la izquierda.
document_verifications: document_verifications:
already_verified: Esta cuenta de usuario ya está verificada. already_verified: Esta cuenta de usuario ya está verificada.
has_no_account_html: Para crear un usuario entre en %{link} y haga clic en la opción <b>'Registrarse'</b> en la parte superior derecha de la pantalla. has_no_account: Para crear un usuario entre en %{link} y haga clic en la opción <b>'Registrarse'</b> en la parte superior derecha de la pantalla.
link: CONSUL link: CONSUL
in_census_has_following_permissions: "Este usuario puede participar en el Portal de Gobierno Abierto con las siguientes posibilidades:" in_census_has_following_permissions: "Este usuario puede participar en el Portal de Gobierno Abierto con las siguientes posibilidades:"
not_in_census: Este documento no está registrado. not_in_census: Este documento no está registrado.

View File

@@ -18,7 +18,7 @@ es:
title: "Debates" title: "Debates"
description: "En la sección de %{link} puedes exponer y compartir tu opinión con otras personas sobre temas que te preocupan relacionados con la ciudad. También es un espacio donde generar ideas que a través de las otras secciones de %{org} lleven a actuaciones concretas por parte del Ayuntamiento." description: "En la sección de %{link} puedes exponer y compartir tu opinión con otras personas sobre temas que te preocupan relacionados con la ciudad. También es un espacio donde generar ideas que a través de las otras secciones de %{org} lleven a actuaciones concretas por parte del Ayuntamiento."
link: "debates ciudadanos" link: "debates ciudadanos"
feature_html: "Puedes abrir debates, comentarlos y valorarlos con los botones de <strong>Estoy de acuerdo</strong> o <strong>No estoy de acuerdo</strong>. Para ello tienes que %{link}." feature: "Puedes abrir debates, comentarlos y valorarlos con los botones de <strong>Estoy de acuerdo</strong> o <strong>No estoy de acuerdo</strong>. Para ello tienes que %{link}."
feature_link: "registrarte en %{org}" feature_link: "registrarte en %{org}"
image_alt: "Botones para valorar los debates" image_alt: "Botones para valorar los debates"
figcaption: 'Botones "Estoy de acuerdo" y "No estoy de acuerdo" para valorar los debates.' figcaption: 'Botones "Estoy de acuerdo" y "No estoy de acuerdo" para valorar los debates.'

View File

@@ -57,7 +57,7 @@ es:
edit: edit:
dossier: Informe dossier: Informe
price_html: "Coste (%{currency}) <small>(dato público)</small>" price_html: "Coste (%{currency}) <small>(dato público)</small>"
price_first_year_html: "Coste en el primer año (%{currency}) <small>(opcional, dato no público)</small>" price_first_year: "Coste en el primer año (%{currency}) <small>(opcional, dato no público)</small>"
feasibility: Viabilidad feasibility: Viabilidad
valuation_finished_alert: "¿Estás seguro/a de querer marcar este informe como completado? Una vez hecho, no se puede deshacer la acción." valuation_finished_alert: "¿Estás seguro/a de querer marcar este informe como completado? Una vez hecho, no se puede deshacer la acción."
not_feasible_alert: "Un email será enviado inmediatamente al autor del proyecto con el informe de inviabilidad." not_feasible_alert: "Un email será enviado inmediatamente al autor del proyecto con el informe de inviabilidad."

View File

@@ -1079,7 +1079,7 @@ describe Budget::Investment do
inv2 = create(:budget_investment, :selected, budget: budget, heading: new_york) inv2 = create(:budget_investment, :selected, budget: budget, heading: new_york)
ballot = create(:budget_ballot, user: user, budget: budget, investments: [inv1]) ballot = create(:budget_ballot, user: user, budget: budget, investments: [inv1])
expect(inv2.reason_for_not_being_ballotable_by(user, ballot)).to eq(:different_heading_assigned_html) expect(inv2.reason_for_not_being_ballotable_by(user, ballot)).to eq(:different_heading_assigned)
end end
it "rejects proposals with price higher than current available money" do it "rejects proposals with price higher than current available money" do
@@ -1091,7 +1091,7 @@ describe Budget::Investment do
ballot = create(:budget_ballot, user: user, budget: budget, investments: [inv1]) ballot = create(:budget_ballot, user: user, budget: budget, investments: [inv1])
expect(inv2.reason_for_not_being_ballotable_by(user, ballot)).to eq(:not_enough_money_html) expect(inv2.reason_for_not_being_ballotable_by(user, ballot)).to eq(:not_enough_money)
end end
end end