From 79c1aa07558e7c06ff496ab44ca470e592d449fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 15 Oct 2023 23:55:02 +0200 Subject: [PATCH] Fix "rel" attribute in footer description links We were accidentally filtering this attribute when sanitizing the text since commit 928312e21. --- app/components/layout/footer_component.html.erb | 3 ++- app/components/layout/footer_component.rb | 4 ++++ spec/components/layout/footer_component_spec.rb | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/components/layout/footer_component.html.erb b/app/components/layout/footer_component.html.erb index 0122798b1..3aeb2a9ca 100644 --- a/app/components/layout/footer_component.html.erb +++ b/app/components/layout/footer_component.html.erb @@ -8,7 +8,8 @@

<%= sanitize(t("layouts.footer.description", open_source: open_source_link, - consul: repository_link)) %> + consul: repository_link), + attributes: allowed_link_attributes) %>

diff --git a/app/components/layout/footer_component.rb b/app/components/layout/footer_component.rb index c81d102ac..58278899b 100644 --- a/app/components/layout/footer_component.rb +++ b/app/components/layout/footer_component.rb @@ -14,4 +14,8 @@ class Layout::FooterComponent < ApplicationComponent def repository_link link_to(t("layouts.footer.consul"), t("layouts.footer.consul_url"), rel: "nofollow") end + + def allowed_link_attributes + self.class.sanitized_allowed_attributes + ["rel"] + end end diff --git a/spec/components/layout/footer_component_spec.rb b/spec/components/layout/footer_component_spec.rb index 83b509506..d44e52e01 100644 --- a/spec/components/layout/footer_component_spec.rb +++ b/spec/components/layout/footer_component_spec.rb @@ -6,6 +6,7 @@ describe Layout::FooterComponent do render_inline Layout::FooterComponent.new page.find(".info") do |info| + expect(info).to have_css "a[rel=nofollow]", count: 2 expect(info).not_to have_css "a[target]" end end