Skip to content

Commit

Permalink
Don't escape request.get_full_path() in Django1.8
Browse files Browse the repository at this point in the history
In Django1.8, request.get_full_path() method now escapes
unsafe characters.

Disable the urlquote for containers table when running
in Django1.8.

Closes-Bug: #1482958
Partially Implements: blueprint django18

Change-Id: I4b2051942618ec3b9262a26e2027f17ecb589eb8
  • Loading branch information
lin-hua-cheng committed Aug 9, 2015
1 parent bf1a262 commit 7b4b527
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions openstack_dashboard/dashboards/project/containers/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# under the License.
import logging

import django
from django import shortcuts
from django import template
from django.template import defaultfilters as filters
Expand All @@ -35,6 +36,14 @@
LOADING_IMAGE = '<img src="/static/dashboard/img/loading.gif" />'


def _escape_full_url(url):
# NOTE (lhcheng): In Django 1.8, HttpRequest.get_full_path()
# method now escapes unsafe characters
if django.VERSION < (1, 8):
return http.urlquote(url)
return url


class ViewContainer(tables.LinkAction):
name = "view"
verbose_name = _("View Details")
Expand Down Expand Up @@ -282,7 +291,7 @@ def get_object_id(self, container):

def get_absolute_url(self):
url = super(ContainersTable, self).get_absolute_url()
return http.urlquote(url)
return _escape_full_url(url)

def get_full_url(self):
"""Returns the encoded absolute URL path with its query string.
Expand All @@ -293,7 +302,7 @@ def get_full_url(self):
"""
url = super(ContainersTable, self).get_full_url()
return http.urlquote(url)
return _escape_full_url(url)


class ViewObject(tables.LinkAction):
Expand Down Expand Up @@ -351,7 +360,7 @@ def delete(self, request, obj_id):

def get_success_url(self, request):
url = super(DeleteObject, self).get_success_url(request)
return http.urlquote(url)
return _escape_full_url(url)


class DeleteMultipleObjects(DeleteObject):
Expand Down Expand Up @@ -453,7 +462,7 @@ class Meta(object):

def get_absolute_url(self):
url = super(ObjectsTable, self).get_absolute_url()
return http.urlquote(url)
return _escape_full_url(url)

def get_full_url(self):
"""Returns the encoded absolute URL path with its query string.
Expand All @@ -464,4 +473,4 @@ def get_full_url(self):
"""
url = super(ObjectsTable, self).get_full_url()
return http.urlquote(url)
return _escape_full_url(url)

0 comments on commit 7b4b527

Please sign in to comment.