Handle unsafe expressions when using startswith/endswith/contains with unsafe expressions. Closes #58

This commit is contained in:
flosch
2010-07-26 16:42:10 +02:00
parent 2f991ac6f1
commit 7ab2e21c10
2 changed files with 10 additions and 0 deletions

View File

@@ -66,6 +66,9 @@ class StringField(BaseField):
regex = r'%s$'
elif op == 'exact':
regex = r'^%s$'
# escape unsafe characters which could lead to a re.error
value = re.escape(value)
value = re.compile(regex % value, flags)
return value