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)
|
||||
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('>','>')
|
||||
|
||||
|
@ -720,9 +720,11 @@ def filter_emojis_only(title, golden=True, count_emojis=False, graceful=False):
|
|||
abort(400)
|
||||
|
||||
title = title.strip()
|
||||
soup = BeautifulSoup(title, 'lxml')
|
||||
text = soup.html.body.text.strip()
|
||||
if not text: title = f'--- {title} ---'
|
||||
|
||||
if is_post_title:
|
||||
soup = BeautifulSoup(title, 'lxml')
|
||||
text = soup.html.body.text.strip()
|
||||
if not text: title = f'--- {title} ---'
|
||||
|
||||
return title
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ def submit_post(v, sub=None):
|
|||
if SITE == 'rdrama.net' and v.id == 10947:
|
||||
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):
|
||||
abort(400, "You can only type marseys!")
|
||||
|
@ -992,7 +992,7 @@ def edit_post(pid, v):
|
|||
|
||||
|
||||
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):
|
||||
abort(403, "You can only type marseys!")
|
||||
|
|
Loading…
Reference in New Issue