use regexp for url_replacer

This commit is contained in:
Sebastian Hugentobler 2015-05-18 16:55:35 +02:00
parent d2a1812a38
commit 73e1b58923

View File

@ -19,7 +19,7 @@ def fromunixtime(value):
return datetime.fromtimestamp(value).strftime('%Y-%m-%d %H:%M:%S') return datetime.fromtimestamp(value).strftime('%Y-%m-%d %H:%M:%S')
def url_replacer(value): def url_replacer(value):
return value.replace('/', '_').replace(' ', '_').replace('?', '').replace('<', '').replace('>', '') return re.sub('[^a-zA-Z0-9\n\.]', '_', value)
def user_replacer(match): def user_replacer(match):
return '[url=../../user/' + url_replacer(match.group(2)) + '.html]' + match.group(2) + '[/url]' return '[url=../../user/' + url_replacer(match.group(2)) + '.html]' + match.group(2) + '[/url]'