summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2016-01-05 12:32:51 +0100
committerMartin Trigaux <mat@odoo.com>2016-01-05 12:34:31 +0100
commit77aee2d78fb75a3cc55f7a8ff45c867e5a26a78d (patch)
tree917238028df98eea182e2925671248daa7c2bd83
parent191128611df02f368a44caeff80e3cdf9f3016e5 (diff)
[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.
-rw-r--r--addons/website_forum/models/forum.py1
1 files changed, 1 insertions, 0 deletions
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'<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: