X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=89957cb47833944472c51f384783d9c6fd0a4f50;hb=07e67fc794333105b8832ff4f9aa70d407c6b8f3;hp=5048e4407e4dff457a62ee94394f2dfaae0fbd70;hpb=d7b4beaeb975c55f5203aef275c7c01853fa51f2;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 5048e4407..89957cb47 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -3434,7 +3434,19 @@ sub _quote { && driver_name eq 'Pg' ) { - dbh->quote($value, { pg_type => PG_BYTEA() }); + local $@; + + eval { $value = dbh->quote($value, { pg_type => PG_BYTEA() }); }; + + if ( $@ && $@ =~ /Wide character/i ) { + warn 'Correcting malformed UTF-8 string for binary quote()' + if $DEBUG; + utf8::decode($value); + utf8::encode($value); + $value = dbh->quote($value, { pg_type => PG_BYTEA() }); + } + + $value; } else { dbh->quote($value); }