Skip to content

Commit d35f949

Browse files
theWorstComradeidank
authored andcommitted
options: fix pathological spacing issues with regex
https://huntr.dev/bounties/c85354c7-4490-4fad-a32c-03f9f4bdcb63/
1 parent ebc5e9f commit d35f949

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

explainshell/options.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def extract(manpage):
2323
opt_regex = re.compile(r'''
2424
(?P<opt>--?(?:\?|\#|(?:\w+-)*\w+)) # option starts with - or -- and can have - in the middle but not at the end, also allow '-?'
2525
(?:
26-
(?:\s*(=)?\s*) # -a=
26+
(?:\s?(=)?\s?) # -a=
2727
(?P<argoptional>[<\[])? # -a=< or -a=[
28-
(?:\s*(=)?\s*) # or maybe -a<=
28+
(?:\s?(=)?\s?) # or maybe -a<=
2929
(?P<arg>
3030
(?(argoptional) # if we think we have an arg (we saw [ or <)
3131
[^\]>]+ # either read everything until the closing ] or >
@@ -39,7 +39,7 @@ def extract(manpage):
3939
)
4040
(?(argoptional)(?P<argoptionalc>[\]>])) # read closing ] or > if we have an arg
4141
)? # the whole arg thing is optional
42-
(?P<ending>,\s*|\s+|\Z|/|\|)''', re.X) # read any trailing whitespace or the end of the string
42+
(?P<ending>,\s*|\s+|\Z|/|\|)''', re.X) # read any trailing whitespace or the end of the string
4343

4444
opt2_regex = re.compile(r'''
4545
(?P<opt>\w+) # an option that doesn't start with any of the usual characters, e.g. options from 'dd' like bs=BYTES

0 commit comments

Comments
 (0)