summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Jackson <mitch@freeside.biz>2018-09-29 18:48:39 -0400
committerMitch Jackson <mitch@freeside.biz>2018-09-29 18:58:17 -0400
commitb6088672c87e2c5984183326b4c0e2d9bd6c34f6 (patch)
tree009aa103a93e9d6bbf2885d66a0525301bdf4b19
parent8fe6c833babe44bb707b8c47273b04fe39edfbaf (diff)
RT# 79705 Correct UTF-8 output for generated E-Mail
-rw-r--r--FS/FS/Record.pm14
1 files changed, 13 insertions, 1 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index e951178cc..9dd08cfd8 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -3641,7 +3641,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);
}