From b3b1b699c773418dd0e9319220d99d65630f35be Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 9 Jan 2012 15:58:13 +0100 Subject: [PATCH] =?utf8?q?File::Temp=20f=C3=BCr=20Erzeugung=20tempor=C3=A4?= =?utf8?q?rer=20Dateinamen=20nutzen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix für Bug 1747. --- SL/Form.pm | 25 +++++++++++-------------- bin/mozilla/ustva.pl | 5 +---- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index 5393c4719..f100b8c90 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1094,19 +1094,16 @@ sub parse_template { # OUT is used for the media, screen, printer, email # for postscript we store a copy in a temporary file - my $fileid = time; - my $prepend_userspath; - - if (!$self->{tmpfile}) { - $self->{tmpfile} = "${fileid}.$self->{IN}"; - $prepend_userspath = 1; - } - - $prepend_userspath = 1 if substr($self->{tmpfile}, 0, length $userspath) eq $userspath; - - $self->{tmpfile} =~ s|.*/||; - $self->{tmpfile} =~ s/[^a-zA-Z0-9\._\ \-]//g; - $self->{tmpfile} = "$userspath/$self->{tmpfile}" if $prepend_userspath; + my ($temp_fh, $suffix); + $suffix = $self->{IN}; + $suffix =~ s/.*\.//; + ($temp_fh, $self->{tmpfile}) = File::Temp::tempfile( + 'lx-office-printXXXXXX', + SUFFIX => '.' . ($suffix || 'tex'), + DIR => $userspath, + UNLINK => 1, + ); + close $temp_fh; if ($template->uses_temp_file() || $self->{media} eq 'email') { $out = $self->{OUT}; @@ -1152,7 +1149,7 @@ sub parse_template { $mail->{charset} = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET; $mail->{to} = $self->{EMAIL_RECIPIENT} ? $self->{EMAIL_RECIPIENT} : $self->{email}; $mail->{from} = qq|"$myconfig->{name}" <$myconfig->{email}>|; - $mail->{fileid} = "$fileid."; + $mail->{fileid} = time() . '.' . $$ . '.'; $myconfig->{signature} =~ s/\r//g; # if we send html or plain text inline diff --git a/bin/mozilla/ustva.pl b/bin/mozilla/ustva.pl index c455740be..a3c464211 100644 --- a/bin/mozilla/ustva.pl +++ b/bin/mozilla/ustva.pl @@ -848,7 +848,6 @@ sub generate_ustva { #file suffix $file .= '.xml'; $file =~ s|.*/||; - $form->{tmpfile} = "$::lx_office_conf{paths}{userspath}/$file"; $form->{attachment_filename} = $file; @@ -894,11 +893,9 @@ sub generate_ustva { # Define serveral filenames $form->{IN} = 'taxbird.txb'; - $form->{attachment_filename} = "USTVA-" . $form->{period} - . sprintf("%02d", $form->{year} % 100) . ".txb"; + $form->{attachment_filename} = "USTVA-" . ($form->{period} * 1) . sprintf("%02d", $form->{year} % 100) . ".txb"; $form->{attachment_filename} =~ s|.*/||; - $form->{tmpfile} = "$::lx_office_conf{paths}{userspath}/" . $form->{attachment_filename}; # TODO: set Output to UTF-8 or system Preference #$form->{"iconv"} = Text::Iconv->new($myconfig{dbcharset}, "UTF-8"); -- 2.20.1