Skip to content

Commit

Permalink
Fix code scanning alert no. 99: 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
1 parent 128dcdd commit 559678f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion routes/editPost.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
RECAPTCHA_SECRET_KEY, # Recaptcha secret key
generateurlID, # urlID generator from post title
)
import re

# Create a blueprint for the edit post route
editPostBlueprint = Blueprint("editPost", __name__)
Expand Down Expand Up @@ -322,4 +323,7 @@ def editPost(urlID):
category="error",
language=session["language"],
) # Display a flash message
return redirect(f"/login/redirect=&editpost&{urlID}")
if re.match(r'^[a-zA-Z0-9\-]+$', urlID):
return redirect(f"/login/redirect=&editpost&{urlID}")
else:
return redirect('/login')

0 comments on commit 559678f

Please sign in to comment.