forked from rDrama/rDrama
remove weird spaces annoying me
parent
7ee7868185
commit
0cae055403
|
@ -78,7 +78,7 @@ def get_users(usernames, v=None, graceful=False):
|
||||||
def clean(n):
|
def clean(n):
|
||||||
return n.replace('\\', '').replace('_', '\_').replace('%', '').strip()
|
return n.replace('\\', '').replace('_', '\_').replace('%', '').strip()
|
||||||
|
|
||||||
usernames = [ clean(n) for n in usernames ]
|
usernames = [clean(n) for n in usernames]
|
||||||
|
|
||||||
users = g.db.query(User).filter(
|
users = g.db.query(User).filter(
|
||||||
or_(
|
or_(
|
||||||
|
|
|
@ -244,14 +244,14 @@ def sanitize(sanitized, edit=False, limit_pings=False, showmore=True):
|
||||||
|
|
||||||
v = getattr(g, 'v', None)
|
v = getattr(g, 'v', None)
|
||||||
|
|
||||||
matches = [ m for m in mention_regex.finditer(sanitized) if m ]
|
matches = [m for m in mention_regex.finditer(sanitized) if m]
|
||||||
names = set( m.group(2) for m in matches )
|
names = set( m.group(2) for m in matches )
|
||||||
if limit_pings and len(names) > 3 and not v.admin_level: abort(406)
|
if limit_pings and len(names) > 3 and not v.admin_level: abort(406)
|
||||||
users = get_users(names, graceful=True)
|
users = get_users(names, graceful=True)
|
||||||
|
|
||||||
for u in users:
|
for u in users:
|
||||||
if not u: continue
|
if not u: continue
|
||||||
m = [ m for m in matches if u.username.lower() == m.group(2).lower() or u.original_username.lower() == m.group(2).lower() ]
|
m = [m for m in matches if u.username.lower() == m.group(2).lower() or u.original_username.lower() == m.group(2).lower()]
|
||||||
for i in m:
|
for i in m:
|
||||||
if not (v and v.any_block_exists(u)) or (v and v.admin_level >= 2):
|
if not (v and v.any_block_exists(u)) or (v and v.admin_level >= 2):
|
||||||
sanitized = sanitized.replace(i.group(0), f'''{i.group(1)}<a href="/id/{u.id}"><img loading="lazy" src="/pp/{u.id}">@{u.username}</a>''', 1)
|
sanitized = sanitized.replace(i.group(0), f'''{i.group(1)}<a href="/id/{u.id}"><img loading="lazy" src="/pp/{u.id}">@{u.username}</a>''', 1)
|
||||||
|
|
Loading…
Reference in New Issue