Don't use unsanitzed file paths as regexps
authorNeil Mayhew <neil_mayhew@sil.org>
Fri, 10 Feb 2012 17:11:26 +0000 (10 10:11 -0700)
committerLove Hörnquist Åstrand <lha@kth.se>
Sun, 12 Feb 2012 17:45:23 +0000 (12 09:45 -0800)
This causes an error if, eg, a path contains parentheses

Signed-off-by: Love Hörnquist Åstrand <lha@kth.se>
git2svn

diff --git a/git2svn b/git2svn
index 90009b6..9ac6d38 100755 (executable)
--- 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";