From 73e1b58923213a1664f148cfe2ecd41a8a336f9e Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Mon, 18 May 2015 16:55:35 +0200 Subject: [PATCH] use regexp for url_replacer --- generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator.py b/generator.py index f33576b..fd2dcc4 100755 --- a/generator.py +++ b/generator.py @@ -19,7 +19,7 @@ def fromunixtime(value): return datetime.fromtimestamp(value).strftime('%Y-%m-%d %H:%M:%S') def url_replacer(value): - return value.replace('/', '_').replace(' ', '_').replace('?', '').replace('<', '').replace('>', '') + return re.sub('[^a-zA-Z0-9\n\.]', '_', value) def user_replacer(match): return '[url=../../user/' + url_replacer(match.group(2)) + '.html]' + match.group(2) + '[/url]'