1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6 from fnpdjango.utils.text import char_map
8 # PayU chokes on non-Polish diacritics.
9 # Punctuation is handled correctly and escaped as needed,
10 # with the notable exception of backslash.
11 sane_in_payu_title = re.escape(
12 string.ascii_uppercase +
13 string.ascii_lowercase +
14 'ąćęłńóśźżĄĆĘŁŃÓŚŹŻ' +
17 "".join(set(string.punctuation) - set('\\'))
23 return char_map.get(char, '')
26 def sanitize_payment_title(value):
27 return re.sub('[^%s]' % sane_in_payu_title, replace_char, str(value))