Aevann 2023-03-02 03:15:04 +02:00
parent 4dde817fcc
commit 9eba456031
2 changed files with 22 additions and 22 deletions

View File

@ -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'<section id="signature-{self.author.id}" class="user-signature"><hr>{self.author.sig_html}</section>'

View File

@ -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'<section id="signature-{self.author.id}" class="user-signature"><hr>{self.author.sig_html}</section>'