UX: support links in tag descriptions (#22994)

* scrub non-a html tags from tag descriptions on create, strips all tags from tag description when displayed in tag hover

* test for tag description links

* UX: basic render-tag test

* UX: fix linting

* UX: fix linting

* fix broken tests

* Update spec/models/tag_spec.rb

Co-authored-by: Penar Musaraj <pmusaraj@gmail.com>

* UX: use has_sanitizable_fields instead of has_scrubbable_fields to ensafen tag.description

---------

Co-authored-by: Penar Musaraj <pmusaraj@gmail.com>
This commit is contained in:
marstall
2023-08-16 11:43:54 -04:00
committed by GitHub
parent 9643151419
commit 77626c088e
7 changed files with 50 additions and 6 deletions

View File

@@ -54,7 +54,7 @@ describe "Viewing sidebar as anonymous user", type: :system do
expect(sidebar).to have_tags_section
expect(sidebar).to have_all_tags_section_link
expect(sidebar).to have_tag_section_links([tag3, tag2, tag4, tag5, tag1])
expect(sidebar).to have_tag_section_link_with_title(tag1, "tag 1 description &lt;script&gt;")
expect(sidebar).to have_tag_section_link_with_title(tag1, "tag 1 description ")
end
it "should display the site's top tags when `default_navigation_menu_tags` site setting has been set but the tags configured are hidden to the user" do
@@ -66,7 +66,7 @@ describe "Viewing sidebar as anonymous user", type: :system do
expect(sidebar).to have_tags_section
expect(sidebar).to have_all_tags_section_link
expect(sidebar).to have_tag_section_links([tag3, tag2, tag4, tag1, tag6])
expect(sidebar).to have_tag_section_link_with_title(tag1, "tag 1 description &lt;script&gt;")
expect(sidebar).to have_tag_section_link_with_title(tag1, "tag 1 description ")
end
it "should display the tags configured in `default_navigation_menu_tags` site setting when it has been set" do

View File

@@ -162,7 +162,7 @@ describe "Viewing sidebar as logged in user", type: :system do
expect(sidebar).to have_tags_section
expect(sidebar).to have_tag_section_links([tag3, tag2, tag4, tag5, tag1])
expect(sidebar).to have_tag_section_link_with_title(tag3, "tag 3 description")
expect(sidebar).to have_tag_section_link_with_title(tag1, "tag 1 description &lt;script&gt;")
expect(sidebar).to have_tag_section_link_with_title(tag1, "tag 1 description ")
expect(sidebar).to have_all_tags_section_link
end
@@ -177,7 +177,7 @@ describe "Viewing sidebar as logged in user", type: :system do
expect(sidebar).to have_tags_section
expect(sidebar).to have_tag_section_links([tag1, tag2, tag3])
expect(sidebar).to have_tag_section_link_with_title(tag3, "tag 3 description")
expect(sidebar).to have_tag_section_link_with_title(tag1, "tag 1 description &lt;script&gt;")
expect(sidebar).to have_tag_section_link_with_title(tag1, "tag 1 description ")
expect(sidebar).to have_all_tags_section_link
end
end