[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1563] trunk/LedgerSMB/Template



Revision: 1563
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1563&view=rev
Author:   tetragon
Date:     2007-09-11 08:18:39 -0700 (Tue, 11 Sep 2007)

Log Message:
-----------
Fixing hash and object escaping

Modified Paths:
--------------
    trunk/LedgerSMB/Template/CSV.pm
    trunk/LedgerSMB/Template/HTML.pm
    trunk/LedgerSMB/Template/PDF.pm
    trunk/LedgerSMB/Template/PS.pm

Modified: trunk/LedgerSMB/Template/CSV.pm
===================================================================
--- trunk/LedgerSMB/Template/CSV.pm	2007-09-11 14:47:32 UTC (rev 1562)
+++ trunk/LedgerSMB/Template/CSV.pm	2007-09-11 15:18:39 UTC (rev 1563)
@@ -58,11 +58,7 @@
 		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 @@
 		$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;
 }

Modified: trunk/LedgerSMB/Template/HTML.pm
===================================================================
--- trunk/LedgerSMB/Template/HTML.pm	2007-09-11 14:47:32 UTC (rev 1562)
+++ trunk/LedgerSMB/Template/HTML.pm	2007-09-11 15:18:39 UTC (rev 1563)
@@ -60,15 +60,14 @@
         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;
 }
 

Modified: trunk/LedgerSMB/Template/PDF.pm
===================================================================
--- trunk/LedgerSMB/Template/PDF.pm	2007-09-11 14:47:32 UTC (rev 1562)
+++ trunk/LedgerSMB/Template/PDF.pm	2007-09-11 15:18:39 UTC (rev 1563)
@@ -57,15 +57,15 @@
 		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;
 }

Modified: trunk/LedgerSMB/Template/PS.pm
===================================================================
--- trunk/LedgerSMB/Template/PS.pm	2007-09-11 14:47:32 UTC (rev 1562)
+++ trunk/LedgerSMB/Template/PS.pm	2007-09-11 15:18:39 UTC (rev 1563)
@@ -51,8 +51,23 @@
 	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 {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.