From d35f949af4e4391a7e563d260dd102b80aeeb545 Mon Sep 17 00:00:00 2001 From: theWorstComrade <4lbercik@gmail.com> Date: Sun, 26 Dec 2021 22:08:53 +0100 Subject: [PATCH] options: fix pathological spacing issues with regex https://huntr.dev/bounties/c85354c7-4490-4fad-a32c-03f9f4bdcb63/ --- explainshell/options.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/explainshell/options.py b/explainshell/options.py index 9b8d359e..7abdd07f 100644 --- a/explainshell/options.py +++ b/explainshell/options.py @@ -23,9 +23,9 @@ def extract(manpage): opt_regex = re.compile(r''' (?P--?(?:\?|\#|(?:\w+-)*\w+)) # option starts with - or -- and can have - in the middle but not at the end, also allow '-?' (?: - (?:\s*(=)?\s*) # -a= + (?:\s?(=)?\s?) # -a= (?P[<\[])? # -a=< or -a=[ - (?:\s*(=)?\s*) # or maybe -a<= + (?:\s?(=)?\s?) # or maybe -a<= (?P (?(argoptional) # if we think we have an arg (we saw [ or <) [^\]>]+ # either read everything until the closing ] or > @@ -39,7 +39,7 @@ def extract(manpage): ) (?(argoptional)(?P[\]>])) # read closing ] or > if we have an arg )? # the whole arg thing is optional - (?P,\s*|\s+|\Z|/|\|)''', re.X) # read any trailing whitespace or the end of the string + (?P,\s*|\s+|\Z|/|\|)''', re.X) # read any trailing whitespace or the end of the string opt2_regex = re.compile(r''' (?P\w+) # an option that doesn't start with any of the usual characters, e.g. options from 'dd' like bs=BYTES