]> git.openstreetmap.org Git - rails.git/commitdiff
fix formatting of tag values with semicolon-separated URLs
authorKyle Hensel <k.y.l.e@outlook.co.nz>
Sat, 31 Dec 2022 03:37:29 +0000 (16:37 +1300)
committerKyle Hensel <k.y.l.e@outlook.co.nz>
Sat, 31 Dec 2022 04:30:03 +0000 (17:30 +1300)
app/helpers/browse_tags_helper.rb
test/helpers/browse_tags_helper_test.rb

index 0784d03caefabca670e501f9ee0160373fcc0869..b7c12ca608abc4392b73afc1bb715c1c66aabe34 100644 (file)
@@ -32,7 +32,7 @@ module BrowseTagsHelper
     elsif colour_value = colour_preview(key, value)
       tag.span("", :class => "colour-preview-box", :"data-colour" => colour_value, :title => t("browse.tag_details.colour_preview", :colour_value => colour_value)) + colour_value
     else
-      linkify h(value)
+      safe_join(h(value).split(";").map{|x| linkify(x) }, ";")
     end
   end
 
index 3f36b921092618a45e1ea2625c33d025d4dba46c..2329a7c961d8f23b28cc9d0ccf2fe80211ade425 100644 (file)
@@ -49,6 +49,12 @@ class BrowseTagsHelperTest < ActionView::TestCase
 
     html = format_value("contact", "foo@example.com")
     assert_dom_equal "<a title=\"Email foo@example.com\" href=\"mailto:foo@example.com\">foo@example.com</a>", html
+
+    html = format_value("source", "https://example.com")
+    assert_dom_equal "<a href=\"https://example.com\" rel=\"nofollow\">https://example.com</a>", html
+
+    html = format_value("source", "https://example.com;hello;https://example.net")
+    assert_dom_equal "<a href=\"https://example.com\" rel=\"nofollow\">https://example.com</a>;hello;<a href=\"https://example.net\" rel=\"nofollow\">https://example.net</a>", html
   end
 
   def test_wiki_link