openstreetmap-website icon indicating copy to clipboard operation
openstreetmap-website copied to clipboard

Handle whitespace in social links username display

Open uw-amy-bordenave opened this issue 3 months ago • 5 comments

Description

Bug Report: Display username is truncated at whitespace in HDYC link. Note: Link functionality itself is not impacted and works as expected.

URL

https://www.openstreetmap.org/user/UW%20Amy%20Bordenave

How to reproduce the issue?

  1. Open OSM /user/ page
  2. "Edit Profile Details"
  3. "Edit Links"
  4. "Add Social Link"
  5. Enter in a URL to HDYC that contains spaces (or percent-encoded spaces), ex. https://hdyc.neis-one.org/?UW Amy Bordenave or https://hdyc.neis-one.org/?UW%20Amy%20Bordenave
  6. Note that the display username is cut off at the space.

Screenshot(s) or anything else?

Image

uw-amy-bordenave avatar Sep 26 '25 00:09 uw-amy-bordenave

Thank you for the report! 🙂

The issue seems to be with the regular expressions used to parse the social links. The one for HDYC should accept spaces, but it doesn't. See app/models/social_link.rb.

This could be a great first issue for new contributors to work on. Anyone up for it? Ideally a PR should also include a unit test, see test/models/social_link_test.rb.

pablobm avatar Sep 29 '25 09:09 pablobm

Hey @pablobm Is it possible that the issue is not with the Regex parsing social links but with text truncation class provided in views/social_links/_show.html.rb

Yatharths11 avatar Oct 24 '25 05:10 Yatharths11

I think not. My understanding is that the CSS class would truncate with an ellipsis: https://getbootstrap.com/docs/5.3/helpers/text-truncation/ instead of disappearing the text without a trace. Also, the regexp is missing a space.

pablobm avatar Oct 24 '25 09:10 pablobm

This bug also occurs with the link to my Wikidata user page, which is Keepright! ler, but shows up as Keepright on my OSM website profile – note that the exclamation point is cut off as well as the space.

Openstreetmapler avatar Nov 07 '25 17:11 Openstreetmapler

Oof, looks like MediaWiki (and by extension Wikidata, Wikipedia, etc) are quite liberal in what they accept as user names. My PHP is very rusty, but this function appears to be relevant: https://github.com/wikimedia/mediawiki/blob/fedec340e5c5841bf2916dce57e7249bf2d5f1e4/includes/Title/Title.php#L423

pablobm avatar Nov 11 '25 12:11 pablobm