diff options
author | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-11 15:18:39 +0000 |
---|---|---|
committer | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-11 15:18:39 +0000 |
commit | 8b641aca011d4ae738e5b4c327bd2532e1b0ed66 (patch) | |
tree | ef0ea215216df3f71ae304fe2c4b1792bdaa8fb3 | |
parent | 9f82c1f3c2215c7bb14d38ffa9aa58c6fbd02095 (diff) |
Fixing hash and object escaping
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1563 4979c152-3d1c-0410-bac9-87ea11338e46
-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 { |