### Description
Fixes #6614.

This PR updates the `RichText#linkify_users` method to support user mentions 
containing spaces by allowing quoted syntax (e.g., `@"Open Mapper"`).

**Key changes:**
* **Updated Regex:** Now detects mentions enclosed in quotes.
* **Quote Handling:** Supports straight quotes (`"`), smart quotes (`“”`), 
and escaped entities (`"`), ensuring compatibility with the Markdown 
renderer.
* **Email Protection:** Added a negative lookbehind `(?<!\w)` to ensure that 
email addresses (e.g., `[email protected]`) are not accidentally parsed as 
mentions.
* **Prevented Double-Linking:** The visible `@` symbol is replaced with the 
HTML entity `@` to prevent subsequent parsers (like 
`expand_link_shorthands`) from detecting the mention a second time.

### How has this been tested?
* **New Test Case:** Added `test_linkify_username_with_space` to 
`test/lib/rich_text_test.rb` to verify that quoted mentions are correctly 
parsed into relative links with safe HTML output.
* **Regression Testing:** Ran the full `RichTextTest` suite (`bundle exec rails 
test test/lib/rich_text_test.rb`) to confirm that standard mentions (`@user`) 
and email addresses still function correctly.
* **Linting:** Verified code style compliance using `rubocop`.
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/6616

-- Commit Summary --

  * Fix issue #6614: Support spaces in @mentions using quotes

-- File Changes --

    M lib/rich_text.rb (11)
    M test/lib/rich_text_test.rb (12)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/6616.patch
https://github.com/openstreetmap/openstreetmap-website/pull/6616.diff

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

Message ID: <openstreetmap/openstreetmap-website/pull/[email protected]>
_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to