From c3fd0f27813b8f55f0627b6b712e0663df333e0f Mon Sep 17 00:00:00 2001 From: Marek Marecki Date: Tue, 3 May 2016 20:42:30 +0200 Subject: [PATCH] Fix: handling regex characters in path patterns Before this commit if a regex-special character was present on the commandline as a part of path pattern autojump would fail with `sre_constants.error`. --- bin/autojump | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/autojump b/bin/autojump index 5595d14..61c43bd 100755 --- a/bin/autojump +++ b/bin/autojump @@ -279,7 +279,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).replace('\\', '\\\\') + regex_no_sep_end # noqa + regex_needle = regex_one_sep.join(map(re.escape, needles)).replace('\\', '\\\\') + regex_no_sep_end # noqa regex_flags = re.IGNORECASE | re.UNICODE if ignore_case else re.UNICODE found = lambda entry: re.search( regex_needle,