From b4cdf1900c310520029e6deb06422424a1c63fc1 Mon Sep 17 00:00:00 2001 From: Mendel E Date: Mon, 29 Jul 2019 20:41:37 -0400 Subject: [PATCH] Call shlex.split() only after validating cmd, try/except it. --- pyrogram/client/filters/filters.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pyrogram/client/filters/filters.py b/pyrogram/client/filters/filters.py index c785d7d1..0c0bc82c 100644 --- a/pyrogram/client/filters/filters.py +++ b/pyrogram/client/filters/filters.py @@ -246,10 +246,15 @@ class Filters: if text: for p in flt.p: if text.startswith(p): - s = split(text, posix=flt.psx) - c, a = s[0][len(p):], s[1:] + c = text[len(p):].split(None, 1)[0] 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 return bool(message.command)