From 77aee2d78fb75a3cc55f7a8ff45c867e5a26a78d Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 5 Jan 2016 12:32:51 +0100 Subject: [PATCH] [FIX] website_forum: escape link content The links present in forum messages are parsed to integrate "nofollow" attribuate in it. In case the content of the link contains some special char (e.g. foo)bar) the regex fails as it interprates the content as an invalid expression. --- addons/website_forum/models/forum.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index c271b0cdef7..57f9313938f 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -386,6 +386,7 @@ class Post(models.Model): forum = self.env['forum.forum'].browse(forum_id) if content and self.env.user.karma < forum.karma_dofollow: for match in re.findall(r'', content): + match = re.escape(match) # replace parenthesis or special char in regex content = re.sub(match, match[:3] + 'rel="nofollow" ' + match[3:], content) if self.env.user.karma <= forum.karma_editor: