Skip to content

Fix URL encoding for community names in notification links #155

Open
xenacode-art wants to merge 12 commits intom2b3:testfrom
xenacode-art:fix/url-encode-community-name-in-notifications
Open

Fix URL encoding for community names in notification links #155
xenacode-art wants to merge 12 commits intom2b3:testfrom
xenacode-art:fix/url-encode-community-name-in-notifications

Conversation

@xenacode-art
Copy link
Copy Markdown

@xenacode-art xenacode-art commented Mar 16, 2026

Closes #119

Problem I noticed

In-app notification link fields were building URL paths using raw
community.name values. Community names containing special characters
such as + or spaces produced malformed paths — e.g.
/community/GSoC+2026/requests — which browsers misinterpret,
causing 404s when users click through from their notification panel.

Fix I Implemented

Applied urllib.parse.quote(community.name, safe='') to every
notification link that embeds a community name in the path. This
matches the encoding already used in send_emails.py for email links.

Files changed:

  • communities/api_join.py — join request received + approved notifications
  • communities/articles_api.py — article submitted notification
  • articles/api.py — article submitted notification (community context)

Testing

# Community name with special chars
community.name = "GSoC+2026"

# Before
link = f"/community/{community.name}/requests"
# → /community/GSoC+2026/requests  ← broken

# After
link = f"/community/{quote(community.name, safe='')}/requests"
# → /community/GSoC%2B2026/requests  ← correct

armanalam03 and others added 12 commits December 14, 2025 20:23
Sync Alphatest with Test
Sync Main with AlphaTest
Sync test with alphatest
Sync main with Alphatest
Sync AlphaTest with Test
Sync Main with Alphatest
change MAX_COMMUNITIES_PER_USER to 40
change MAX_COMMUNITIES_PER_USER to 40
Community names containing special characters (e.g. '+', spaces) were
being inserted raw into notification link paths, causing 404s when
users clicked through. Apply urllib.parse.quote(..., safe='') to all
in-app notification links that include the community name in the path.

Fixes m2b3#119
@xenacode-art xenacode-art changed the base branch from main to test March 22, 2026 20:39
@armanalam03
Copy link
Copy Markdown
Collaborator

armanalam03 commented Mar 22, 2026

@xenacode-art There have been couple of changes in the test branch regarding Notifications. Would request you to sync your changes. Before raising a new PR, please check again if this issue is re-occurring on https://test.scicommons.org/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect URL Encoding for Community Names with Special Characters in Notifications

2 participants