9 lines
246 B
Python
9 lines
246 B
Python
"""Escape user input for SQL ILIKE patterns."""
|
|
|
|
|
|
def escape_ilike_pattern(value: str) -> str:
|
|
text = (value or "").strip()
|
|
if not text:
|
|
return text
|
|
return text.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_")
|