@matheusbsbs / matheus-bagliano / commits / 4f2e94c0f7
Fork 0

Fix sed string regex escaping in module_name.

When escaping a string to be used as a sed regex, it is important to only escape active characters. Escaping other characters is undefined according to POSIX, and in practice leads to issues with extensions such as GNU sed's \+. Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ralf Wildenhues committed Nov 8, 2007 at 22:48 UTC 4f2e94c0f7685f9c58e67b0651147684efb0f57e
1 file changed +1 -1
git-submodule.sh
+1 -1
@@ -47,7 +47,7 @@ get_repo_base() {
47 module_name()
48 {
49 # Do we have "submodule.<something>.path = $1" defined in .gitmodules file?
50 - re=$(printf '%s' "$1" | sed -e 's/\([^a-zA-Z0-9_]\)/\\\1/g')
50 + re=$(printf '%s' "$1" | sed -e 's/[].[^$\\*]/\\&/g')
51 name=$( GIT_CONFIG=.gitmodules \
52 git config --get-regexp '^submodule\..*\.path$' |
53 sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' )