Handle whitespace in social links username display
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?
- Open OSM /user/ page
- "Edit Profile Details"
- "Edit Links"
- "Add Social Link"
- Enter in a URL to HDYC that contains spaces (or percent-encoded spaces), ex.
https://hdyc.neis-one.org/?UW Amy Bordenaveorhttps://hdyc.neis-one.org/?UW%20Amy%20Bordenave - Note that the display username is cut off at the space.
Screenshot(s) or anything else?
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.
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
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.
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.
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