Skip to content

Commit

Permalink
Fix code scanning alert no. 98: 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 683fb41 commit f9db932
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion routes/editPost.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@
generateurlID, # urlID generator from post title
)
import re
from urllib.parse import urlparse

# Create a blueprint for the edit post route
editPostBlueprint = Blueprint("editPost", __name__)

VALID_URL_IDS = ["validUrlId1", "validUrlId2", "validUrlId3"] # Example list of valid urlIDs

def is_valid_url_id(url_id):
return url_id in VALID_URL_IDS

# Define a route for editing a post
@editPostBlueprint.route("/editpost/<urlID>", methods=["GET", "POST"])
Expand Down Expand Up @@ -286,7 +291,10 @@ def editPost(urlID):
category="success",
language=session["language"],
) # Display a flash message
return redirect(f"/post/{sessionUrlId}")
if is_valid_url_id(sessionUrlId):
return redirect(f"/post/{sessionUrlId}")
else:
return redirect('/')
# Render the edit post template
return render_template(
"/editPost.html.jinja",
Expand Down

0 comments on commit f9db932

Please sign in to comment.