Skip to content
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

Change usages of is_safe_url to use new allowed_hosts instead of host #18329

Merged
merged 1 commit into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/djangoapps/student/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,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