Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2953 - Url resolved with special characters #3725

Merged
merged 3 commits into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion readthedocs/profiles/urls/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


urlpatterns = [
url(r'^(?P<username>[\[email protected]]+)/$',
url(r'^(?P<username>[+\[email protected]]+)/$',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the correct regex here is:

[\w@\.\+-]+

which follows the same as the django validation field from the username.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@humitos no need to -1 yourself haha

views.profile_detail,
{'template_name': 'profiles/public/profile_detail.html'},
name='profiles_profile_detail'),
Expand Down
22 changes: 22 additions & 0 deletions readthedocs/rtd_tests/tests/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,25 @@ def test_version_url_with_caps(self):
kwargs={'type_': 'pdf', 'version_slug': u'1.4.X', 'project_slug': u'django'}
)
self.assertTrue(url)


class TestProfileDetailURLs(TestCase):

def test_profile_detail_url(self):
url = reverse(
'profiles_profile_detail',
kwargs={'username': 'foo+bar'}
)
self.assertEqual(url, '/profiles/foo+bar/')

url = reverse(
'profiles_profile_detail',
kwargs={'username': '[email protected]'}
)
self.assertEqual(url, '/profiles/[email protected]/')

url = reverse(
'profiles_profile_detail',
kwargs={'username': 'abc-def+ghi'}
)
self.assertEqual(url, '/profiles/abc-def+ghi/')