Skip to content

Commit

Permalink
Fix code scanning alert no. 81: URL redirection from remote source
Browse files Browse the repository at this point in the history
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
Badatos and github-advanced-security[bot] authored Nov 21, 2024
1 parent 097edab commit 151af7c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pod/playlist/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from django.shortcuts import get_object_or_404, redirect, render
from django.template.loader import render_to_string
from django.views.decorators.csrf import csrf_protect, ensure_csrf_cookie
from django.http import Http404, HttpResponseBadRequest, JsonResponse
from django.http import Http404, HttpResponseBadRequest, JsonResponse, HttpResponseRedirect
from django.utils.http import url_has_allowed_host_and_scheme
from django.db import transaction

from pod.main.utils import is_ajax
Expand Down Expand Up @@ -224,7 +225,11 @@ def toggle_render_playlist_user_has_right(
messages.ERROR,
_("The password is incorrect."),
)
return redirect(request.headers["referer"])
referer = request.headers.get("referer", "/")
if url_has_allowed_host_and_scheme(referer, allowed_hosts=None):
return redirect(referer)
else:
return redirect('/')
else:
form = PlaylistPasswordForm()
return render(
Expand Down

0 comments on commit 151af7c

Please sign in to comment.