summaryrefslogtreecommitdiff
path: root/FS/FS/Record.pm
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 19:09:12 -0400
commit8971fb03cc8bf443294331dedc262d68f4d0f60e (patch)
tree10f0b624638413a2ae5b439d53c1d55bc9b384cc /FS/FS/Record.pm
parentf222a656ebe712021d004000ac83df6e69dd3677 (diff)
RT# 79705 Correct UTF-8 output for generated E-Mail
Diffstat (limited to 'FS/FS/Record.pm')
-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 08d681e..ce12a16 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -3629,7 +3629,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);
}