Merge pull request #81 from aguzererler/fix-is-empty-dos-vulnerability-11032456762221174271
This commit is contained in:
commit
f293f6447c
11
cli/main.py
11
cli/main.py
|
|
@ -899,8 +899,6 @@ def extract_content_string(content):
|
||||||
"""Extract string content from various message formats.
|
"""Extract string content from various message formats.
|
||||||
Returns None if no meaningful text content is found.
|
Returns None if no meaningful text content is found.
|
||||||
"""
|
"""
|
||||||
import ast
|
|
||||||
|
|
||||||
def is_empty(val):
|
def is_empty(val):
|
||||||
"""Check if value is empty using Python's truthiness."""
|
"""Check if value is empty using Python's truthiness."""
|
||||||
if val is None or val == "":
|
if val is None or val == "":
|
||||||
|
|
@ -909,10 +907,11 @@ def extract_content_string(content):
|
||||||
s = val.strip()
|
s = val.strip()
|
||||||
if not s:
|
if not s:
|
||||||
return True
|
return True
|
||||||
try:
|
# Check for common string representations of "empty" values
|
||||||
return not bool(ast.literal_eval(s))
|
# to avoid using unsafe ast.literal_eval
|
||||||
except (ValueError, SyntaxError):
|
if s.lower() in ("[]", "{}", "()", "none", "false", "0", "0.0", '""', "''"):
|
||||||
return False # Can't parse = real text
|
return True
|
||||||
|
return False
|
||||||
return not bool(val)
|
return not bool(val)
|
||||||
|
|
||||||
if is_empty(content):
|
if is_empty(content):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue