X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FTemplate%2FOpenDocument.pm;h=2ed3c60fa89db36100ff2bf0c1c47050a2ac8ba2;hb=38aac441bd2735f2af58e82f009e8369cf8afb0c;hp=626d3c0bf7e5681c758a1cbd677b2ef3728e44e5;hpb=439e45e4d2ae4d410a4d6b27371b34ff0af5baa9;p=kivitendo-erp.git diff --git a/SL/Template/OpenDocument.pm b/SL/Template/OpenDocument.pm index 626d3c0bf..2ed3c60fa 100644 --- a/SL/Template/OpenDocument.pm +++ b/SL/Template/OpenDocument.pm @@ -3,6 +3,7 @@ package SL::Template::OpenDocument; use parent qw(SL::Template::Simple); use Archive::Zip; +use Encode; use POSIX 'setsid'; use SL::Iconv; @@ -109,21 +110,27 @@ sub parse_block { $contents =~ m|^(.*?)(]*>)|; my $table_row = $1; my $end_tag = $2; - substr($contents, 0, length($1) + length($end_tag)) = ""; if ($table_row =~ m|\<\%foreachrow\s+(.*?)\%\>|) { my $var = $1; - substr($table_row, length($`), length($&)) = ""; + $contents =~ m|\<\%foreachrow\s+.*?\%\>|; + substr($contents, length($`), length($&)) = ""; - my ($t1, $t2) = $self->find_end($table_row, length($`)); - if (!$t1) { + ($table_row, $contents) = $self->find_end($contents, length($`)); + if (!$table_row) { $self->{"error"} = "Unclosed <\%foreachrow\%>." unless ($self->{"error"}); $main::lxdebug->leave_sub(); return undef; } - my $new_text = $self->parse_foreach($var, $t1 . $t2, $tag, $end_tag, @indices); + $contents =~ m|^(.*?)(]*>)|; + $table_row .= $1; + $end_tag = $2; + + substr $contents, 0, length($&), ''; + + my $new_text = $self->parse_foreach($var, $table_row, $tag, $end_tag, @indices); if (!defined($new_text)) { $main::lxdebug->leave_sub(); return undef; @@ -131,6 +138,7 @@ sub parse_block { $new_contents .= $new_text; } else { + substr($contents, 0, length($table_row) + length($end_tag)) = ""; my $new_text = $self->parse_block($table_row, @indices); if (!defined($new_text)) { $main::lxdebug->leave_sub(); @@ -221,7 +229,7 @@ sub parse { return 0; } - my $contents = $zip->contents("content.xml"); + my $contents = Encode::decode('utf-8-strict', $zip->contents("content.xml")); if (!$contents) { $self->{"error"} = "File is not a OpenDocument file."; $main::lxdebug->leave_sub(); @@ -260,7 +268,7 @@ sub parse { # $new_contents =~ s|>|>\n|g; - $zip->contents("content.xml", $new_contents); + $zip->contents("content.xml", Encode::encode('utf-8-strict', $new_contents)); my $styles = $zip->contents("styles.xml"); if ($contents) {