Skip to content

Commit

Permalink
Fix code scanning alert no. 91: Uncontrolled data used in path expres…
Browse files Browse the repository at this point in the history
…sion

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
1 parent e8ad2f7 commit 00be32f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions utils/flashMessage.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from modules import (
load, # Import the load function from the modules module
flash, # Import the flash function from the modules module
Expand All @@ -21,9 +22,10 @@ def flashMessage(
None
"""
text = None # Initialize the text variable
translationFile = (
f"./translations/{language}.json" # Define the path to the translation file
)
base_path = "./translations"
translationFile = os.path.normpath(os.path.join(base_path, f"{language}.json")) # Define the path to the translation file
if not translationFile.startswith(base_path):
raise Exception("Invalid language path")
match exists(translationFile): # Check if the translation file exists
case True:
# If the translation file exists, open and load the JSON data
Expand Down

0 comments on commit 00be32f

Please sign in to comment.