From: Neil Mayhew Date: Fri, 10 Feb 2012 17:11:26 +0000 (-0700) Subject: Don't use unsanitzed file paths as regexps X-Git-Url: https://repo.or.cz/w/git2svn.git/commitdiff_plain/c5a99a63738fc61260e878248b05befee2003a24 Don't use unsanitzed file paths as regexps This causes an error if, eg, a path contains parentheses Signed-off-by: Love Hörnquist Åstrand --- diff --git a/git2svn b/git2svn index 90009b6..9ac6d38 100755 --- a/git2svn +++ b/git2svn @@ -192,6 +192,11 @@ sub auto_props return ""; } +sub isPrefix +{ + my ($prefix, $string) = (shift, shift); + return $prefix eq substr($string, 0, length($prefix)); +} $|= 1; @@ -402,8 +407,9 @@ COMMAND: while (!eof(IN)) { if ($paths{$path}) { delete $paths{$path}; + $path .= "/"; foreach ( keys( %paths ) ) { - delete $paths{$_} if ( /^$path\// ); + delete $paths{$_} if ( isPrefix($path, $_) ); } printf OUT "Node-path: $path\n";