Error in Bulk action and next_page GET parameter is None

Issue #112 resolved
Rémi Fat Cheung created an issue

Hi,

In UpdateMessageMixin there is a line:

return redirect(_get_safe_internal_url(request.GET.get('next')) or self.success_url or next_url)

The _get_safe_internal_url(request.GET.get('next')) is throwing an error 'NoneType' object has no attribute 'find' when this view is called with POST (which is the case with bulk actions). Maybe it should have a default value that is not None, or the _get_safe_internal_url should handle these.

Thanks!

Comments (5)

  1. Patrick Samson repo owner
    • changed status to open

    Please give more details, I can't see where this 'find' comes from:
    request.GET is never None.
    request.GET.get('next') just returns None if the key is not present.
    _get_safe_internal_url(None) is supported.

  2. Rémi Fat Cheung reporter

    Here is the end of my stacktrace (I'm still using python 2.7 Django 1.11, in the process of upgrading soon):

    File "/home/vagrant/virtualenvs/myenv/local/lib/python2.7/site-packages/postman/views.py" in post
      433.             return redirect(_get_safe_internal_url(request.GET.get('next')) or self.success_url or next_url)
    
    File "/home/vagrant/virtualenvs/myenv/local/lib/python2.7/site-packages/postman/views.py" in _get_safe_internal_url
      56.     sr = urlsplit(urlstring)
    
    File "/usr/lib/python2.7/urlparse.py" in urlsplit
      182.     i = url.find(':')
    
    Exception Type: AttributeError at /profile/messages/archive/
    Exception Value: 'NoneType' object has no attribute 'find'
    

    I also just tried in a shell:

    >>> from urlparse import urlsplit
    >>> urlsplit(None)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python2.7/urlparse.py", line 182, in urlsplit
        i = url.find(':')
    AttributeError: 'NoneType' object has no attribute 'find
    
  3. Patrick Samson repo owner

    Ah! py2! That's why.
    My fault, I tend to neglect to check the test suite for that case.
    Anyway, easy to fix ; will be done soon.

  4. Log in to comment