From 4cebfa3e5d8d8e5e791517fe237482f38d7da523 Mon Sep 17 00:00:00 2001 From: Jacob Carlborg Date: Sat, 20 May 2023 07:18:34 +0200 Subject: [PATCH] Fix for paths containing characters with special meaning in regex If running a Git command (like diff) for a project located in a path containing characters which have special meaning in regular expressions the command will crash. The fix sanitizes the path by escaping characters with special meaning. --- Support/lib/git.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Support/lib/git.rb b/Support/lib/git.rb index a0f5dcc..3758da3 100644 --- a/Support/lib/git.rb +++ b/Support/lib/git.rb @@ -106,7 +106,8 @@ def dir_part(file_or_dir) end def make_local_path(fullpath) - fullpath = fullpath.gsub(/#{path}\/{0,1}/, "") + sanitized_path = Regexp.escape(path) + fullpath = fullpath.gsub(/#{sanitized_path}\/{0,1}/, "") fullpath = "." if fullpath == "" fullpath end