diff options
| author | Mitch Jackson <mitch@freeside.biz> | 2018-09-29 18:48:39 -0400 | 
|---|---|---|
| committer | Mitch Jackson <mitch@freeside.biz> | 2018-09-29 18:49:53 -0400 | 
| commit | 07e67fc794333105b8832ff4f9aa70d407c6b8f3 (patch) | |
| tree | 7e3355143e82b5749de84d9e529c35f22b45fd6f | |
| parent | a5e01af2ff2d6b291a98a28ceeda0ca0089945ea (diff) | |
RT# 79705 Correct UTF-8 output for generated E-Mail
| -rw-r--r-- | FS/FS/Record.pm | 14 | 
1 files changed, 13 insertions, 1 deletions
| 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);    } | 
