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