fix: sanitize SQL queries by removing trailing semicolons
This commit is contained in:
parent
dde61f447d
commit
3fbb41b980
1 changed files with 3 additions and 0 deletions
|
|
@ -86,6 +86,9 @@ class DataQueryService:
|
|||
"""
|
||||
max_limit = settings.SQL_ROW_LIMIT
|
||||
|
||||
# Strip trailing semicolons and whitespace to prevent multi-statement errors
|
||||
query = query.rstrip("; \t\n\r")
|
||||
|
||||
# Remove comments and normalize whitespace for parsing
|
||||
cleaned_query = re.sub(r"--.*$", "", query, flags=re.MULTILINE)
|
||||
cleaned_query = re.sub(r"/\*.*?\*/", "", cleaned_query, flags=re.DOTALL)
|
||||
|
|
|
|||
Loading…
Reference in a new issue