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

Conversation

Projects
None yet
5 participants
@bansalnitish
Contributor

bansalnitish commented Mar 3, 2018

This PR Fixes #2953. I have added the + character to the username set. Rest all characters letters , numbers, - and _ were already doing fine with the URL.

@bansalnitish

This comment has been minimized.

Contributor

bansalnitish commented Mar 4, 2018

Any updates on this PR ?

@ericholscher

This comment has been minimized.

Member

ericholscher commented Mar 5, 2018

Thanks for the patch! This could use a test confirming that it does indeed work for projects with +'s. Similar to this: https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/rtd_tests/tests/test_views.py#L115-L124

@bansalnitish

This comment has been minimized.

Contributor

bansalnitish commented Mar 6, 2018

Thanks for the review @ericholscher! I will add a test for this!

@bansalnitish

This comment has been minimized.

Contributor

bansalnitish commented Mar 6, 2018

@ericholscher Can you please guide about where these tests should be added?

@RichardLitt RichardLitt requested a review from ericholscher Mar 7, 2018

@ericholscher

This comment has been minimized.

Member

ericholscher commented Mar 8, 2018

I linked the tests file above: https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/rtd_tests/tests/test_views.py#L115-L124

You could also test the regex itself, outside of a view, and just confirm that it's matching what we expect.

@bansalnitish

This comment has been minimized.

Contributor

bansalnitish commented Mar 8, 2018

@ericholscher I have added the tests!

def test_project_details_resolve(self):
self.project.users.add(self.user)
response = self.client.get('/projects/my-mainproject/')

This comment has been minimized.

@stsewd

stsewd Mar 8, 2018

Member

I think this should test for the user profile /profiles/{user}/

This comment has been minimized.

@bansalnitish

bansalnitish Mar 8, 2018

Contributor

I have fixed that as well as added some new users for testing!

@stsewd stsewd referenced this pull request Apr 4, 2018

Closed

Fail. Check back in a bit! #3890

@humitos

Thanks for your contribution!

This solves #3890

@@ -7,7 +7,7 @@
urlpatterns = [
url(r'^(?P<username>[\w@.-]+)/$',
url(r'^(?P<username>[+\w@.-]+)/$',

This comment has been minimized.

@humitos

humitos Apr 4, 2018

Member

I think the correct regex here is:

[\w@\.\+-]+

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

This comment has been minimized.

@stsewd

stsewd Apr 4, 2018

Member

@humitos no need to -1 yourself haha

def test_profile_details_page(self):
response = self.client.get('/profiles/foo+bar/')

This comment has been minimized.

@humitos

humitos Apr 4, 2018

Member

Instead of creating these users and accessing the page itself, isn't it better to use the resolver and check that it matches?

This comment has been minimized.

@bansalnitish

bansalnitish Apr 13, 2018

Contributor

Hi @humitos, Sorry for the delay on this. I was busy with class tests in my college.
Can you please elaborate on this as I am a bit confused about how to proceed.

This comment has been minimized.

@humitos

humitos Apr 17, 2018

Member

Sorry, I meant the reverse function from django:

In [1]: from django.core.urlresolvers import reverse

In [3]: reverse('profiles_profile_detail', kwargs={'username': 'foo+bar'})
Out[3]: '/profiles/foobar/'

and check the URL returned with assertEqual.

This comment has been minimized.

@bansalnitish

bansalnitish Apr 17, 2018

Contributor

Thanks for the explanation @humitos, I have made the changes!

@humitos

This comment has been minimized.

Member

humitos commented May 10, 2018

Merging, Thanks!

@humitos humitos removed the Needed: tests label May 10, 2018

@humitos humitos merged commit 696a25f into rtfd:master May 10, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@bansalnitish bansalnitish deleted the bansalnitish:fixUrl branch May 10, 2018

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