[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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user