Skip to content

Commit

Permalink
Merge pull request openedx#18329 from edx/bmedx/is_safe_url_allowed_h…
Browse files Browse the repository at this point in the history
…osts

Change usages of is_safe_url to use new allowed_hosts instead of host
  • Loading branch information
bmedx authored Jun 7, 2018
2 parents 9f820c9 + 29ad5fc commit ca0ec64
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/djangoapps/student/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def get_redirect_to(request):
# get information about a user on edx.org. In any such case drop the parameter.
if redirect_to:
mime_type, _ = mimetypes.guess_type(redirect_to, strict=False)
if not http.is_safe_url(redirect_to, host=request.get_host()):
if not http.is_safe_url(redirect_to, allowed_hosts={request.get_host()}):
log.warning(
u'Unsafe redirect parameter detected after login page: %(redirect_to)r',
{"redirect_to": redirect_to}
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/student/views/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ def target(self):
"""
target_url = self.request.GET.get('redirect_url')

if target_url and is_safe_url(target_url, self.request.META.get('HTTP_HOST')):
if target_url and is_safe_url(target_url, allowed_hosts={self.request.META.get('HTTP_HOST')}):
return target_url
else:
return self.default_target
Expand Down
2 changes: 1 addition & 1 deletion openedx/core/djangoapps/external_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def _safe_postlogin_redirect(redirect_to, safehost, default_redirect='/'):
@param safehost: which host is safe to redirect to
@return: an HttpResponseRedirect
"""
if is_safe_url(url=redirect_to, host=safehost):
if is_safe_url(url=redirect_to, allowed_hosts={safehost}):
return redirect(redirect_to)
return redirect(default_redirect)

Expand Down

0 comments on commit ca0ec64

Please sign in to comment.