forked from rDrama/rDrama
restrict the behavior added in last commit to post titles only
parent
990791e59b
commit
b06fc47a02
|
@ -697,7 +697,7 @@ def allowed_attributes_emojis(tag, name, value):
|
||||||
|
|
||||||
|
|
||||||
@with_sigalrm_timeout(2)
|
@with_sigalrm_timeout(2)
|
||||||
def filter_emojis_only(title, golden=True, count_emojis=False, graceful=False):
|
def filter_emojis_only(title, golden=True, count_emojis=False, graceful=False, is_post_title=False):
|
||||||
|
|
||||||
title = title.replace("\n", "").replace("\r", "").replace("\t", "").replace('<','<').replace('>','>')
|
title = title.replace("\n", "").replace("\r", "").replace("\t", "").replace('<','<').replace('>','>')
|
||||||
|
|
||||||
|
@ -720,6 +720,8 @@ def filter_emojis_only(title, golden=True, count_emojis=False, graceful=False):
|
||||||
abort(400)
|
abort(400)
|
||||||
|
|
||||||
title = title.strip()
|
title = title.strip()
|
||||||
|
|
||||||
|
if is_post_title:
|
||||||
soup = BeautifulSoup(title, 'lxml')
|
soup = BeautifulSoup(title, 'lxml')
|
||||||
text = soup.html.body.text.strip()
|
text = soup.html.body.text.strip()
|
||||||
if not text: title = f'--- {title} ---'
|
if not text: title = f'--- {title} ---'
|
||||||
|
|
|
@ -436,7 +436,7 @@ def submit_post(v, sub=None):
|
||||||
if SITE == 'rdrama.net' and v.id == 10947:
|
if SITE == 'rdrama.net' and v.id == 10947:
|
||||||
sub = 'mnn'
|
sub = 'mnn'
|
||||||
|
|
||||||
title_html = filter_emojis_only(title, graceful=True, count_emojis=True)
|
title_html = filter_emojis_only(title, graceful=True, count_emojis=True, is_post_title=True)
|
||||||
|
|
||||||
if v.marseyawarded and not marseyaward_title_regex.fullmatch(title_html):
|
if v.marseyawarded and not marseyaward_title_regex.fullmatch(title_html):
|
||||||
abort(400, "You can only type marseys!")
|
abort(400, "You can only type marseys!")
|
||||||
|
@ -992,7 +992,7 @@ def edit_post(pid, v):
|
||||||
|
|
||||||
|
|
||||||
if title != p.title:
|
if title != p.title:
|
||||||
title_html = filter_emojis_only(title, golden=False)
|
title_html = filter_emojis_only(title, golden=False, is_post_title=True)
|
||||||
|
|
||||||
if v.id == p.author_id and v.marseyawarded and not marseyaward_title_regex.fullmatch(title_html):
|
if v.id == p.author_id and v.marseyawarded and not marseyaward_title_regex.fullmatch(title_html):
|
||||||
abort(403, "You can only type marseys!")
|
abort(403, "You can only type marseys!")
|
||||||
|
|
Loading…
Reference in New Issue