2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Call shlex.split() only after validating cmd, try/except it.

This commit is contained in:
Mendel E 2019-07-29 20:41:37 -04:00
parent 584a6a046a
commit b4cdf1900c

View File

@ -246,10 +246,15 @@ class Filters:
if text: if text:
for p in flt.p: for p in flt.p:
if text.startswith(p): if text.startswith(p):
s = split(text, posix=flt.psx) c = text[len(p):].split(None, 1)[0]
c, a = s[0][len(p):], s[1:]
c = c if flt.cs else c.lower() c = c if flt.cs else c.lower()
message.command = ([c] + a) if c in flt.c else None if c not in flt.c:
return False
try:
a = split(text, posix=flt.psx)[1:]
message.command = ([c] + a)
except ValueError as e:
message.command = {"text": text[len(p):], "error": e}
break break
return bool(message.command) return bool(message.command)