forked from rDrama/rDrama
1
0
Fork 0

better handling of large emojis in places where they're not allowed

master
Aevann 2023-07-22 13:10:27 +03:00
parent d865e1e86a
commit 37c9307fc4
3 changed files with 5 additions and 5 deletions

View File

@ -5509,7 +5509,7 @@ input[type=radio] ~ .custom-control-label::before {
height: 60px;
width: 60px;
}
.bigemoji, .emoji-lg, img[alt^=":"][alt*="#"] {
.bigemoji, .emoji-lg, img[alt^=":"][alt*="#"]:not([t]) {
height: 150px;
width: 150px;
}

View File

@ -52,7 +52,6 @@ mute_regex = re.compile("\/mute @?([\w\-]{3,30}) ([0-9]+)", flags=re.A|re.I)
emoji_regex = re.compile(f"<p>\s*(:[!#@\w\-]{{1,36}}:\s*)+<\/p>", flags=re.A)
emoji_regex2 = re.compile(f'(?<!"):([!#@\w\-]{{1,36}}?):(?!([^<]*<\/(code|pre)>|[^`]*`))', flags=re.A)
emoji_regex3 = re.compile(f'(?<!"):([!@\w\-]{{1,35}}?):', flags=re.A)
snappy_url_regex = re.compile('<a href="(https?:\/\/.+?)".*?>(.+?)<\/a>', flags=re.A)
snappy_youtube_regex = re.compile('<lite-youtube videoid="(.+?)" params="autoplay=1', flags=re.A)

View File

@ -213,7 +213,7 @@ def execute_blackjack(v, target, body, kind):
send_repeatable_notification_duplicated(id, f"Blackjack by @{v.username}: {extra_info}")
return True
def render_emoji(html, regexp, golden, emojis_used, b=False):
def render_emoji(html, regexp, golden, emojis_used, b=False, is_title=False):
emojis = list(regexp.finditer(html))
captured = set()
@ -224,6 +224,7 @@ def render_emoji(html, regexp, golden, emojis_used, b=False):
emoji = i.group(1).lower()
attrs = ''
if b: attrs += ' b'
if is_title: attrs += ' t'
if golden and len(emojis) <= 20 and ('marsey' in emoji or emoji in marseys_const2):
if random.random() < 0.0025: attrs += ' g'
elif random.random() < 0.00125: attrs += ' glow'
@ -609,7 +610,7 @@ def allowed_attributes_emojis(tag, name, value):
if name == 'src' and value.startswith('/') and '\\' not in value: return True
if name == 'loading' and value == 'lazy': return True
if name == 'data-bs-toggle' and value == 'tooltip': return True
if name in {'g','glow'} and not value: return True
if name in {'g','glow','t'} and not value: return True
if name in {'alt','title'}: return True
if tag == 'span':
@ -631,7 +632,7 @@ def filter_emojis_only(title, golden=True, count_emojis=False, graceful=False, s
emojis_used = set()
title = render_emoji(title, emoji_regex3, golden, emojis_used)
title = render_emoji(title, emoji_regex2, golden, emojis_used, is_title=True)
if count_emojis:
for emoji in g.db.query(Emoji).filter(Emoji.submitter_id==None, Emoji.name.in_(emojis_used)).all():