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

SF.net SVN: ledger-smb:[4723] branches/1.3



Revision: 4723
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4723&view=rev
Author:   einhverfr
Date:     2012-05-18 13:35:38 +0000 (Fri, 18 May 2012)
Log Message:
-----------
Improved CSV escaping for numbers with decimals and minus signs

Modified Paths:
--------------
    branches/1.3/Changelog
    branches/1.3/LedgerSMB/Template/CSV.pm
    branches/1.3/UI/lib/dynatable.csv

Modified: branches/1.3/Changelog
===================================================================
--- branches/1.3/Changelog	2012-05-18 12:38:47 UTC (rev 4722)
+++ branches/1.3/Changelog	2012-05-18 13:35:38 UTC (rev 4723)
@@ -5,6 +5,7 @@
 Changelog for 1.3.18
 * Fixed missing template for CSV pricelists (Chris T)
 * Added ODS pricelists (Chris T)
+* Better CSV escaping (Chris T, h/t Erik H)
 
 Changelog for 1.3.17
 * Address now shows on ECA selection screen (Erik H)

Modified: branches/1.3/LedgerSMB/Template/CSV.pm
===================================================================
--- branches/1.3/LedgerSMB/Template/CSV.pm	2012-05-18 12:38:47 UTC (rev 4722)
+++ branches/1.3/LedgerSMB/Template/CSV.pm	2012-05-18 13:35:38 UTC (rev 4723)
@@ -75,10 +75,11 @@
 		}
 		$vars =~ s/(^ +| +$)//g;
 		$vars =~ s/"/""/g;
-		$vars = qq|"$vars"| if $vars !~ /^\w*$/;
+		$vars = qq|"$vars"| if $vars =~ /[^0-9.+-]/;
+                warn $vars;
 	} else { # hashes and objects
 		for ( keys %{$rawvars} ) {
-			$vars->{preprocess($_)} = preprocess( $rawvars->{$_} );
+			$vars->{$_} = preprocess( $rawvars->{$_} );
 		}
 	}
 	return $vars;

Modified: branches/1.3/UI/lib/dynatable.csv
===================================================================
--- branches/1.3/UI/lib/dynatable.csv	2012-05-18 12:38:47 UTC (rev 4722)
+++ branches/1.3/UI/lib/dynatable.csv	2012-05-18 13:35:38 UTC (rev 4723)
@@ -1,6 +1,6 @@
 <?lsmb- BLOCK escape;
 
-IF VALUE.match('\D'); # any non-digit means run escaping
+IF VALUE.match('[^0-9.+-]'); # any non-digit means run escaping
    '"' _ VALUE.replace('"', '""') _ '"';
 ELSE;
    VALUE;

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