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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -241,3 +241,30 @@ def test_project_admins_can_delete_subprojects_that_they_are_not_admin_of(self): | |
'/dashboard/my-mainproject/subprojects/my-subproject/delete/') | ||
self.assertEqual(response.status_code, 302) | ||
self.assertTrue(self.subproject not in [r.child for r in self.project.subprojects.all()]) | ||
|
||
class URLResolution(TestCase): | ||
def setUp(self): | ||
self.user1 = new(User, username='foo+bar') | ||
self.user1.set_password('test1') | ||
self.user1.save() | ||
|
||
self.user2 = new(User, username='abc+def@ghi.jkl') | ||
self.user2.set_password('test2') | ||
self.user2.save() | ||
|
||
self.user3 = new(User, username='abc-def+ghi') | ||
self.user3.set_password('test3') | ||
self.user3.save() | ||
|
||
self.client.login(username='foo+bar', password='test1') | ||
|
||
def test_profile_details_page(self): | ||
|
||
response = self.client.get('/profiles/foo+bar/') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of creating these users and accessing the page itself, isn't it better to use the resolver and check that it matches? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @humitos, Sorry for the delay on this. I was busy with class tests in my college. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I meant the
and check the URL returned with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the explanation @humitos, I have made the changes! |
||
self.assertEqual(response.status_code, 200) | ||
|
||
response = self.client.get('/profiles/abc+def@ghi.jkl/') | ||
self.assertEqual(response.status_code, 200) | ||
|
||
response = self.client.get('/profiles/abc-def+ghi/') | ||
self.assertEqual(response.status_code, 200) |
There was a problem hiding this comment.
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:
which follows the same as the django validation field from the
username
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forget about this comment, @stsewd is right here: #3890 (comment)
https://stackoverflow.com/questions/19976018/does-a-dot-have-to-be-escaped-in-a-character-class-square-brackets-of-a-regula
There was a problem hiding this comment.
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