I am getting an error when trying to print an invoice in CSV format:

Error!
Not a HASH reference at LedgerSMB/Template/CSV.pm line 80.

I am using ledgersmb 1.3.22.


LedgerSMB::Template::CSV::preprocess() is trying to dereference a CODE
reference as a hash.

I can't think of any situation when it makes sense for preprocess() to
dereference a CODE reference, and believe it should simply return in this
situation. (but perhaps I am missing something?)

The following patch would achieve that:

--- CSV.original.pm     2012-06-17 11:13:17.000000000 +0100
+++ CSV.pm      2012-09-13 09:40:05.460722650 +0100
@@ -74,10 +74,12 @@
                        $vars = $rawvars;
                }
                $vars =~ s/(^ +| +$)//g;
                $vars =~ s/"/""/g;
                $vars = qq|"$vars"| if $vars =~ /[^0-9.+-]/;
+       } elsif ( $type eq 'CODE' ) { # a code reference makes no sense
+               return;
        } else { # hashes and objects
                for ( keys %{$rawvars} ) {
                        $vars->{$_} = preprocess( $rawvars->{$_} );
                }
        }


Perhaps a deeper problem is why preprocess() is being passed a code
reference?  With the above patch applied, I then get a different error:

file error - invoice.csv: not found at LedgerSMB/Template/CSV.pm line 122.






------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ledger-smb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel

Reply via email to