Improved apostrophe escaping.

This commit is contained in:
Dave Hall 2014-09-17 10:12:42 +01:00
parent fb446b611c
commit b3d677db2b

View file

@ -23,6 +23,7 @@ def regex_from_word(word):
def make_escaper(badchars):
"""Creates an efficient escape function that strips the given characters from the string."""
translation_table = dict((ord(c), None) for c in badchars)
translation_table[ord("'")] = "''"
def escaper(text):
return force_text(text, errors="ignore").translate(translation_table)
return escaper