Form::parse_template: "Content-disposition: attachment"-Header nur ausgeben, wenn...
authorMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 19 Aug 2013 09:19:00 +0000 (11:19 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 19 Aug 2013 09:21:26 +0000 (11:21 +0200)
Fixt #2351.

SL/Form.pm

index f0d13de..5fd0e68 100644 (file)
@@ -1156,16 +1156,22 @@ sub parse_template {
         seek  IN, 0, 0;
 
       } else {
-        $self->{attachment_filename} = ($self->{attachment_filename})
-                                     ? $self->{attachment_filename}
-                                     : $self->generate_attachment_filename();
-
-        # launch application
-        print qq|Content-Type: | . $template->get_mime_type() . qq|
-Content-Disposition: attachment; filename="$self->{attachment_filename}"
-Content-Length: $numbytes
+        my %headers = ('-type'       => $template->get_mime_type,
+                       '-connection' => 'close',
+                       '-charset'    => 'UTF-8');
+
+        $self->{attachment_filename} ||= $self->generate_attachment_filename;
+
+        if ($self->{attachment_filename}) {
+          %headers = (
+            %headers,
+            '-attachment'     => $self->{attachment_filename},
+            '-content-length' => $numbytes,
+            '-charset'        => '',
+          );
+        }
 
-|;
+        print $::request->cgi->header(%headers);
 
         $::locale->with_raw_io(\*STDOUT, sub { print while <IN> });
       }