mirror of
https://github.com/wting/autojump
synced 2024-10-27 20:34:07 +00:00
Escape backslashes in regexps (match_anywhere/match_consecutive)
Fixes https://github.com/joelthelion/autojump/issues/281
This commit is contained in:
parent
27a01662a5
commit
95472620c7
@ -241,7 +241,7 @@ def match_anywhere(needles, haystack, ignore_case=False):
|
||||
(path="/moo/foo/baz", weight=10),
|
||||
(path="/foo/baz", weight=10)]
|
||||
"""
|
||||
regex_needle = '.*' + '.*'.join(needles) + '.*'
|
||||
regex_needle = '.*' + '.*'.join(needles).replace('\\', '\\\\') + '.*'
|
||||
regex_flags = re.IGNORECASE | re.UNICODE if ignore_case else re.UNICODE
|
||||
found = lambda haystack: re.search(
|
||||
regex_needle,
|
||||
@ -285,7 +285,7 @@ def match_consecutive(needles, haystack, ignore_case=False):
|
||||
regex_no_sep_end = regex_no_sep + '$'
|
||||
regex_one_sep = regex_no_sep + sep + regex_no_sep
|
||||
# can't use compiled regex because of flags
|
||||
regex_needle = regex_one_sep.join(needles) + regex_no_sep_end
|
||||
regex_needle = regex_one_sep.join(needles).replace('\\', '\\\\') + regex_no_sep_end
|
||||
regex_flags = re.IGNORECASE | re.UNICODE if ignore_case else re.UNICODE
|
||||
found = lambda entry: re.search(
|
||||
regex_needle,
|
||||
|
Loading…
Reference in New Issue
Block a user