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

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



Revision: 3518
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3518&view=rev
Author:   einhverfr
Date:     2011-07-15 06:04:04 +0000 (Fri, 15 Jul 2011)

Log Message:
-----------
Translated strings now escaped in templates, and confirmed working in html and latex

Modified Paths:
--------------
    trunk/LedgerSMB/Template/HTML.pm
    trunk/LedgerSMB/Template/LaTeX.pm
    trunk/LedgerSMB/Template.pm

Modified: trunk/LedgerSMB/Template/HTML.pm
===================================================================
--- trunk/LedgerSMB/Template/HTML.pm	2011-07-15 06:01:08 UTC (rev 3517)
+++ trunk/LedgerSMB/Template/HTML.pm	2011-07-15 06:04:04 UTC (rev 3518)
@@ -77,10 +77,18 @@
             $vars->{preprocess($_)} = preprocess( $rawvars->{$_} );
         }
     }
-    
+     
     return $vars;
 }
 
+sub escape {
+    my $vars = shift @_;
+    if (defined $vars){
+        return escapeHTML($vars);
+    }
+    return undef;
+}
+
 sub process {
 	my $parent = shift;
 	my $cleanvars = shift;

Modified: trunk/LedgerSMB/Template/LaTeX.pm
===================================================================
--- trunk/LedgerSMB/Template/LaTeX.pm	2011-07-15 06:01:08 UTC (rev 3517)
+++ trunk/LedgerSMB/Template/LaTeX.pm	2011-07-15 06:04:04 UTC (rev 3518)
@@ -79,10 +79,7 @@
 			$vars = $rawvars;
 		}
 		#XXX Fix escaping
-		if (defined $vars){
-			$vars =~ s/([&\$\\_<>~^#\%\{\}])/\\$1/g;
-			$vars =~ s/"(.*)"/``$1''/gs;
-		}
+		$vars = escape($vars);
 	} else {
 		for ( keys %{$rawvars} ) {
 			$vars->{$_} = preprocess($rawvars->{$_});
@@ -91,6 +88,18 @@
 	return $vars;
 }
 
+
+# Breaking this off to be used separately.
+sub escape {
+    my ($vars) = shift @_;
+
+    if (defined $vars){
+            $vars =~ s/([&\$\\_<>~^#\%\{\}])/\\$1/g;
+            $vars =~ s/"(.*)"/``$1''/gs;
+    }
+    return $vars;
+}
+
 sub process {
 	my $parent = shift;
 	my $cleanvars = shift;

Modified: trunk/LedgerSMB/Template.pm
===================================================================
--- trunk/LedgerSMB/Template.pm	2011-07-15 06:01:08 UTC (rev 3517)
+++ trunk/LedgerSMB/Template.pm	2011-07-15 06:04:04 UTC (rev 3518)
@@ -256,7 +256,7 @@
 	}
 
 	if (UNIVERSAL::isa($self->{locale}, 'LedgerSMB::Locale')){
-		$cleanvars->{text} = sub { return $self->{locale}->text(@_)};
+		$cleanvars->{text} = sub { return $self->escape($self->{locale}->text(@_))};
 	} 
 	else {
             $cleanvars->{text} = sub { return shift @_ };
@@ -284,6 +284,12 @@
 	return $post;
 }
 
+sub escape {
+    my ($self, $vars) = @_;
+    my $format = "LedgerSMB::Template::$self->{format}";
+    return $format->can('escape')->($vars) || $vars;
+} 
+
 sub output {
 	my $self = shift;
 	my %args = @_;


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