[openstreetmap/openstreetmap-website] Restrict linkify shorthand expansion to plain text (PR #6674)

Marwin Hochfelsner notifications at github.com
Thu Jan 8 23:12:43 UTC 2026


@hlfan commented on this pull request.



> @@ -88,25 +88,19 @@ def sanitize(text)
     end
 
     def linkify(text, mode = :urls)
-      ERB::Util.html_escape(text)
-               .then { |html| expand_link_shorthands(html) }
-               .then { |html| expand_host_shorthands(html) }
-               .then { |html| auto_link(html, mode) }
-               .html_safe
+      link_attr = 'rel="nofollow noopener noreferrer" dir="auto"'
+      ERB::Util
+        .html_escape(text)
+        .then { |html| expand_link_shorthands(html) }
+        .then { |html| expand_host_shorthands(html) }
+        .then { |html| Rinku.auto_link(html, mode, link_attr) { |url| shorten_link(shorten_hosts(url)) } }

You already mentioned re-enabling it for markdown later on.
In that case, rather than overwriting the gsub pair generator, I'd like to add flags to this linkify function to toggle the pairs of expanding & shortening. Then having both in the same function makes things easier.

Also, I didn't like having these pairs split in different places.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6674#discussion_r2674216024
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/6674/review/3641688538 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260108/85642cb8/attachment.htm>


More information about the rails-dev mailing list