Skip to content

Commit

Permalink
[Django4 Warning] RemovedInDjango40Warning: django.utils.http.is_safe…
Browse files Browse the repository at this point in the history
…_url() is deprecated in favor of url_has_allowed_host_and_scheme()
  • Loading branch information
agl29 committed Mar 23, 2021
1 parent 70d51a7 commit d055d36
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions desktop/core/src/desktop/middleware.py
Expand Up @@ -43,7 +43,7 @@
from django.http import HttpResponseNotAllowed, HttpResponseForbidden
from django.urls import resolve
from django.http import HttpResponseRedirect, HttpResponse
from django.utils.http import urlquote, is_safe_url
from django.utils.http import urlquote
from django.utils.deprecation import MiddlewareMixin

from hadoop import cluster
Expand All @@ -65,8 +65,10 @@

if sys.version_info[0] > 2:
from django.utils.translation import gettext as _
from django.utils.http import url_has_allowed_host_and_scheme
else:
from django.utils.translation import ugettext as _
from django.utils.http import is_safe_url as url_has_allowed_host_and_scheme


LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -837,7 +839,7 @@ def process_response(self, request, response):
if any(regexp.match(location) for regexp in redirection_patterns):
return response

if is_safe_url(location, allowed_hosts={request.get_host()}):
if url_has_allowed_host_and_scheme(location, allowed_hosts={request.get_host()}):
return response

if request.path in ['/oidc/authenticate/', '/oidc/callback/', '/oidc/logout/', '/hue/oidc_failed/']:
Expand Down

0 comments on commit d055d36

Please sign in to comment.