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.slughifi 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(
15 u'ąćęłńóśźżĄĆĘŁŃÓŚŹŻ' +
18 "".join(set(string.punctuation) - set('\\'))
23 return char_map.get(char, '')
25 def sanitize_payment_title(value):
26 return re.sub('[^%s]{1}' % sane_in_payu_title, replace_char, unicode(value))