gitweb: Quote filename in HTTP Content-Disposition: header
Finish work started by commit a2f3db2 (although not documented in commit message) of quoting using quotemeta the filename in HTTP -content_disposition header. Just in case filename contains end of line character. Also use consistent coding style to compute -content_disposition parameter. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jakub Narebski committed
Sep 26, 2006 at 01:59 UTC
ab41dfbfd4f3f9fedac71550027e9813b11abe3d
1 file changed
+9
-8
gitweb/gitweb.perl
+9
-8
@@ -2320,7 +2320,7 @@ sub git_project_index {
2320
print $cgi->header(
2321
-type => 'text/plain',
2322
-charset => 'utf-8',
2323
- -content_disposition => qq(inline; filename="index.aux"));
2323
+ -content_disposition => 'inline; filename="index.aux"');
2324
2325
foreach my $pr (@projects) {
2326
if (!exists $pr->{'owner'}) {
@@ -2682,7 +2682,7 @@ sub git_blob_plain {
2682
print $cgi->header(
2683
-type => "$type",
2684
-expires=>$expires,
2685
- -content_disposition => "inline; filename=\"$save_as\"");
2685
+ -content_disposition => 'inline; filename="' . quotemeta($save_as) . '"');
2686
undef $/;
2687
binmode STDOUT, ':raw';
2688
print <$fd>;
@@ -2856,10 +2856,11 @@ sub git_snapshot {
2856
2857
my $filename = basename($project) . "-$hash.tar.$suffix";
2858
2859
- print $cgi->header(-type => 'application/x-tar',
2860
- -content_encoding => $ctype,
2861
- -content_disposition => "inline; filename=\"$filename\"",
2862
- -status => '200 OK');
2859
+ print $cgi->header(
2860
+ -type => 'application/x-tar',
2861
+ -content_encoding => $ctype,
2862
+ -content_disposition => 'inline; filename="' . quotemeta($filename) . '"',
2863
+ -status => '200 OK');
2864
2865
my $git_command = git_cmd_str();
2866
open my $fd, "-|", "$git_command tar-tree $hash \'$project\' | $command" or
@@ -3169,7 +3170,7 @@ sub git_blobdiff {
3170
-type => 'text/plain',
3171
-charset => 'utf-8',
3172
-expires => $expires,
3172
- -content_disposition => qq(inline; filename=") . quotemeta($file_name) . qq(.patch"));
3173
+ -content_disposition => 'inline; filename="' . quotemeta($file_name) . '.patch"');
3174
3175
print "X-Git-Url: " . $cgi->self_url() . "\n\n";
3176
@@ -3272,7 +3273,7 @@ sub git_commitdiff {
3273
-type => 'text/plain',
3274
-charset => 'utf-8',
3275
-expires => $expires,
3275
- -content_disposition => qq(inline; filename="$filename"));
3276
+ -content_disposition => 'inline; filename="' . quotemeta($filename) . '"');
3277
my %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});
3278
print <<TEXT;
3279
From: $co{'author'}