Skip to content

Commit

Permalink
avoid html in translation string
Browse files Browse the repository at this point in the history
  • Loading branch information
Cesium-Ice committed May 21, 2024
1 parent 4f4a914 commit ea83a19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,10 @@ def check_user_status
# If the stated suspension end date is after the unban threshold we need to advance a day
suspension_end = suspension_end.next_day(1) if suspension_end > unban_theshold
localized_suspension_end = localize(suspension_end.to_date)
flash[:error] = t("suspension_notice", default: "Your account has been suspended until %{suspended_until}. You may not add or edit content until your suspension has been resolved. Please <a href=\"#{new_abuse_report_path}\">contact Abuse</a> for more information.", suspended_until: localized_suspension_end).html_safe
flash[:error] = t("users.status.suspension_notice", suspended_until: localized_suspension_end, contact_abuse_link: view_context.link_to(t(".contact_abuse"), new_abuse_report_path)).html_safe

else
flash[:error] = t("ban_notice", default: "Your account has been banned. You are not permitted to add or edit archive content. Please <a href=\"#{new_abuse_report_path}\">contact Abuse</a> for more information.").html_safe
flash[:error] = t("users.status.ban_notice", contact_abuse_link: view_context.link_to(t(".contact_abuse"), new_abuse_report_path)).html_safe
end
redirect_to current_user
end
Expand All @@ -419,7 +420,8 @@ def check_user_not_suspended
suspension_end = suspension_end.next_day(1) if suspension_end > unban_theshold
localized_suspension_end = localize(suspension_end.to_date)

flash[:error] = t("suspension_notice", default: "Your account has been suspended until %{suspended_until}. You may not add or edit content until your suspension has been resolved. Please <a href=\"#{new_abuse_report_path}\">contact Abuse</a> for more information.", suspended_until: localized_suspension_end).html_safe
flash[:error] = t("users.status.suspension_notice", suspended_until: localized_suspension_end, contact_abuse_link: view_context.link_to(t(".contact_abuse"), new_abuse_report_path)).html_safe

redirect_to current_user
end

Expand Down
3 changes: 3 additions & 0 deletions config/locales/controllers/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@ en:
one: You may reset your password %{count} more time.
other: You may reset your password %{count} more times.
user_not_found: We couldn't find an account with that email address or username. Please try again.
status:
suspension_notice: "Your account has been suspended until %{suspended_until}. You may not add or edit content until your suspension has been resolved. Please %{contact_abuse_link} for more information."
ban_notice: "Your account has been banned. You are not permitted to add or edit archive content. Please %{contact_abuse_link} for more information."

0 comments on commit ea83a19

Please sign in to comment.