X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=c8216eca83cf3f4f684ba49e7ec9eea3a3e89813;hb=36ac94ae711ab27d5f8d352ed7d2cba2e872ac31;hp=9e1c0e890a93778cd8f707c0188738435ec04d43;hpb=a1937e6377a16bd90f345b77a1cab3ebfbe1a2b1;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 9e1c0e890..c8216eca8 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -55,14 +55,13 @@ FS::UID->install_callback( sub { $conf_encryption = $conf->exists('encryption'); $File::CounterFile::DEFAULT_DIR = $conf->base_dir . "/counters.". datasrc; if ( driver_name eq 'Pg' ) { - eval "use DBD::Pg qw(:pg_types);"; + eval "use DBD::Pg ':pg_types'"; die $@ if $@; } else { eval "sub PG_BYTEA { die 'guru meditation #9: calling PG_BYTEA when not running Pg?'; }"; } } ); - =head1 NAME FS::Record - Database record objects @@ -1989,6 +1988,22 @@ sub ut_money { ''; } +=item ut_moneyn COLUMN + +Check/untaint monetary numbers. May be negative. If there +is an error, returns the error, otherwise returns false. + +=cut + +sub ut_moneyn { + my($self,$field)=@_; + if ($self->getfield($field) eq '') { + $self->setfield($field, ''); + return ''; + } + $self->ut_money($field); +} + =item ut_text COLUMN Check/untaint text. Alphanumerics, spaces, and the following punctuation @@ -2718,7 +2733,10 @@ sub _quote { ) { no strict 'subs'; - dbh->quote($value, PG_BYTEA); +# dbh->quote($value, { pg_type => PG_BYTEA() }); # doesn't work right + # Pg binary string quoting: convert each character to 3-digit octal prefixed with \\, + # single-quote the whole mess, and put an "E" in front. + return ("E'" . join('', map { sprintf('\\\\%03o', ord($_)) } split(//, $value) ) . "'"); } else { dbh->quote($value); }