remove weird spaces annoying me

remotes/1693045480750635534/spooky-22
Aevann1 2022-08-17 21:25:57 +02:00
parent 7ee7868185
commit 0cae055403
2 changed files with 3 additions and 3 deletions

View File

@ -78,7 +78,7 @@ def get_users(usernames, v=None, graceful=False):
def clean(n):
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(
or_(

View File

@ -244,14 +244,14 @@ def sanitize(sanitized, edit=False, limit_pings=False, showmore=True):
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 )
if limit_pings and len(names) > 3 and not v.admin_level: abort(406)
users = get_users(names, graceful=True)
for u in users:
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:
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)