[openstreetmap/openstreetmap-website] Fix issue #6614: Support spaces in @mentions using quotes (PR #6616)

Paul Norman notifications at github.com
Wed Dec 17 07:55:09 UTC 2025


@pnorman requested changes on this pull request.



> @@ -97,6 +99,22 @@ def linkify(text, mode = :urls)
 
     private
 
+    def linkify_users(text)
+      regex = /(?<!\w)@(?:“([^”]+?)”|”([^”]+?)”|‘([^’]+?)’|’([^’]+?)’|"([^"]+?)"|'([^']+?)'|(\w+))/

Is there some way to match that doesn't involve an unreadable regular expression? 

> @@ -97,6 +99,22 @@ def linkify(text, mode = :urls)
 
     private
 
+    def linkify_users(text)
+      regex = /(?<!\w)@(?:“([^”]+?)”|”([^”]+?)”|‘([^’]+?)’|’([^’]+?)’|"([^"]+?)"|'([^']+?)'|(\w+))/

There's also a lot of logic in this regular expression that is not tested. It looks like it matches
- `“”`
- `””`
- `‘’`
- `’’`
- `""`
- `''`

Should we have a test that shows that it doesn't linkify something like `@"foo'`? What happens if there are multiple potential matches? e.g. `@“foo@”bar”`

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

Message ID: <openstreetmap/openstreetmap-website/pull/6616/review/3586433395 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20251216/590044be/attachment.htm>


More information about the rails-dev mailing list