gitweb: Use 's' regexp modifier to secure against filenames with LF
Use 's' (treat string as single line) regexp modifier in git_get_hash_by_path (against future changes, probably unnecessary) and in parse_ls_tree_line (when called with '-z'=>1 option) to secure against filenames containing newline. [jc: the hunk on git_get_hash_by_path was unneeded, and I noticed the regexp was doing unnecessary capture, so fixed it up while I was at it.] Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jakub Narebski committed
Oct 30, 2006 at 22:25 UTC
8b4b94cc7998d6312025fe3350be57c89b803f9c
1 file changed
+2
-2
gitweb/gitweb.perl
+2
-2
@@ -860,7 +860,7 @@ sub git_get_hash_by_path {
860
close $fd or return undef;
861
862
#'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
863
- $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
863
+ $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t/;
864
if (defined $type && $type ne $2) {
865
# type doesn't match
866
return undef;
@@ -1277,7 +1277,7 @@ sub parse_ls_tree_line ($;%) {
1277
my %res;
1278
1279
#'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
1280
- $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/;
1280
+ $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$/s;
1281
1282
$res{'mode'} = $1;
1283
$res{'type'} = $2;