diff --git a/files/classes/comment.py b/files/classes/comment.py index 487c91f83..af61f0fe8 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -249,25 +249,6 @@ class Comment(Base): body = self.body_html or "" - if body: - body = censor_slurs(body, v) - body = normalize_urls_runtime(body, v) - if not v or v.controversial: - captured = [] - for i in controversial_regex.finditer(body): - if i.group(1) in captured: continue - captured.append(i.group(1)) - - url = i.group(1) - p = urlparse(url).query - p = parse_qs(p, keep_blank_values=True) - - if 'sort' not in p: p['sort'] = ['controversial'] - - url_noquery = url.split('?')[0] - body = body.replace(f'"{url}"', f'"{url_noquery}?{urlencode(p, True)}"') - body = body.replace(f'>{url}<', f'>{url_noquery}?{urlencode(p, True)}<') - if self.options: curr = [x for x in self.options if x.exclusive and x.voted(v)] if curr: curr = " value=comment-" + str(curr[0].id) @@ -300,6 +281,25 @@ class Comment(Base): elif not o.created_utc or o.created_utc < 1677622270: body += option_body + if body: + body = censor_slurs(body, v) + body = normalize_urls_runtime(body, v) + if not v or v.controversial: + captured = [] + for i in controversial_regex.finditer(body): + if i.group(1) in captured: continue + captured.append(i.group(1)) + + url = i.group(1) + p = urlparse(url).query + p = parse_qs(p, keep_blank_values=True) + + if 'sort' not in p: p['sort'] = ['controversial'] + + url_noquery = url.split('?')[0] + body = body.replace(f'"{url}"', f'"{url_noquery}?{urlencode(p, True)}"') + body = body.replace(f'>{url}<', f'>{url_noquery}?{urlencode(p, True)}<') + if not self.ghost and self.author.show_sig(v): body += f'

{self.author.sig_html}
' diff --git a/files/classes/submission.py b/files/classes/submission.py index ecf384eb0..ef8720241 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -274,9 +274,6 @@ class Submission(Base): body = self.body_html or "" - body = censor_slurs(body, v) - body = normalize_urls_runtime(body, v) - if self.options: curr = [x for x in self.options if x.exclusive and x.voted(v)] if curr: curr = " value=post-" + str(curr[0].id) @@ -329,6 +326,9 @@ class Submission(Base): elif not o.created_utc or o.created_utc < 1677622270: body += option_body + body = censor_slurs(body, v) + body = normalize_urls_runtime(body, v) + if not listing and not self.ghost and self.author.show_sig(v): body += f'

{self.author.sig_html}
'