Move code that escapes special chars to helper function and use it

in query get_users_by_partial_email
This commit is contained in:
Pea Tyczynska
2018-07-13 15:26:42 +01:00
parent 782a8ab9e7
commit a69dee5e6d
3 changed files with 14 additions and 7 deletions

View File

@@ -115,3 +115,12 @@ def last_n_days(limit_days):
# reverse the countdown, -1 from first two args to ensure it stays 0-indexed
for x in range(limit_days - 1, -1, -1)
]
def escape_special_characters(string):
for special_character in ('\\', '_', '%', '/'):
string = string.replace(
special_character,
'\{}'.format(special_character)
)
return string