diff options
-rwxr-xr-x | LedgerSMB/Template/CSV.pm | 10 | ||||
-rwxr-xr-x | LedgerSMB/Template/HTML.pm | 9 | ||||
-rwxr-xr-x | LedgerSMB/Template/PDF.pm | 10 | ||||
-rwxr-xr-x | LedgerSMB/Template/PS.pm | 19 |
4 files changed, 31 insertions, 17 deletions
diff --git a/LedgerSMB/Template/CSV.pm b/LedgerSMB/Template/CSV.pm index 42324a89..cb861e93 100755 --- a/LedgerSMB/Template/CSV.pm +++ b/LedgerSMB/Template/CSV.pm @@ -58,11 +58,7 @@ sub preprocess { for (@{$rawvars}) { push @{$vars}, preprocess( $_ ); } - } elsif ( $type eq 'HASH' ) { - for ( keys %{$rawvars} ) { - $vars->{preprocess($_)} = preprocess( $rawvars->{$_} ); - } - } else { + } elsif ( !$type ) { # Scalar $vars = $rawvars; $vars =~ s/\ / /; $vars =~ s/(\t\n\r )+/ /g; @@ -71,6 +67,10 @@ sub preprocess { $vars =~ s/<.*?>//g; $vars = qq|"$vars"| if $vars !~ /^\w+$/; $vars = '' if $vars =~ /^""$/; + } else { # hashes and objects + for ( keys %{$rawvars} ) { + $vars->{preprocess($_)} = preprocess( $rawvars->{$_} ); + } } return $vars; } diff --git a/LedgerSMB/Template/HTML.pm b/LedgerSMB/Template/HTML.pm index 2f8ac427..6ec7b833 100755 --- a/LedgerSMB/Template/HTML.pm +++ b/LedgerSMB/Template/HTML.pm @@ -60,15 +60,14 @@ sub preprocess { for (@{$rawvars}) { push @{$vars}, preprocess( $_ ); } - } - elsif ( $type eq 'HASH' ) { + } elsif (!$type) { + return CGI::escapeHTML($rawvars); + } else { # Hashes and objects for ( keys %{$rawvars} ) { $vars->{preprocess($_)} = preprocess( $rawvars->{$_} ); } } - else { - return CGI::escapeHTML($rawvars); - } + return $vars; } diff --git a/LedgerSMB/Template/PDF.pm b/LedgerSMB/Template/PDF.pm index cd244736..9c315d62 100755 --- a/LedgerSMB/Template/PDF.pm +++ b/LedgerSMB/Template/PDF.pm @@ -57,15 +57,15 @@ sub preprocess { for (@{$rawvars}) { push @{$vars}, preprocess($_); } - } elsif ($type eq 'HASH') { - for ( keys %{$rawvars} ) { - $vars->{$_} = preprocess($rawvars->{$_}); - } - } else { + } else (!$type) { #XXX Fix escaping $rawvars =~ s/([&\$\\_<>~^#\%\{\}])/\\$1/g; $rawvars =~ s/"(.*)"/``$1''/gs; return $rawvars; + } else { + for ( keys %{$rawvars} ) { + $vars->{$_} = preprocess($rawvars->{$_}); + } } return $vars; } diff --git a/LedgerSMB/Template/PS.pm b/LedgerSMB/Template/PS.pm index ac58204d..f8c048d0 100755 --- a/LedgerSMB/Template/PS.pm +++ b/LedgerSMB/Template/PS.pm @@ -51,8 +51,23 @@ sub preprocess { my $rawvars = shift; my $vars; my $type = ref $rawvars; - #XXX fix escaping - return $rawvars; + + return $rawvars if $type =~ /^LedgerSMB::Locale/; + if ($type eq 'ARRAY') { + for (@{$rawvars}) { + push @{$vars}, preprocess($_); + } + } else (!$type) { + #XXX Fix escaping + $rawvars =~ s/([&\$\\_<>~^#\%\{\}])/\\$1/g; + $rawvars =~ s/"(.*)"/``$1''/gs; + return $rawvars; + } else { + for ( keys %{$rawvars} ) { + $vars->{$_} = preprocess($rawvars->{$_}); + } + } + return $vars; } sub process { |