[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. <a>foo)bar</a>)
the regex fails as it interprates the content as an invalid expression.
This commit is contained in:
Martin Trigaux
2016-01-05 12:34:31 +01:00
parent 191128611d
commit 77aee2d78f
+1
View File
@@ -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'<a\s.*href=".*?">', 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: