Replace 4-byte utf8 characters with unicode replacement character
authorThomas Schüttler <tschuettler@oxfam.de>
Tue, 8 Jan 2019 12:55:50 +0000 (13:55 +0100)
committerThomas Schüttler <tschuettler@oxfam.de>
Tue, 8 Jan 2019 12:59:34 +0000 (13:59 +0100)
CRM/Mailing/Event/BAO/Bounce.php
tests/phpunit/CRM/Utils/Mail/data/bounces/test_utf8mb4_character.txt

index a3f5af0062ab46bdcba1164105757ce3971a29fd..9a162c83dea1b8582482230d49441268ba4a8678 100644 (file)
@@ -80,6 +80,10 @@ class CRM_Mailing_Event_BAO_Bounce extends CRM_Mailing_Event_DAO_Bounce {
     // replace any invalid unicode characters with replacement characters
     $params['bounce_reason'] = mb_convert_encoding($params['bounce_reason'], 'UTF-8', 'UTF-8');
 
+    // dev/mail#37 Replace 4-byte utf8 characaters with the unicode replacement character
+    // while CiviCRM does not support utf8mb4 for MySQL
+    $params['bounce_reason'] = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $params['bounce_reason']);
+
     // CRM-11989
     $params['bounce_reason'] = mb_strcut($params['bounce_reason'], 0, 254);
 
index 938669939d74bf6c42b7dd9d32949d409360e4ff..f97fdd864cee0bd198d5c17e93e52306d51dca68 100644 (file)
@@ -12,4 +12,4 @@ Auto-Submitted: auto-replied (vacation)
 Content-Type: text/plain; charset="utf-8"
 Content-Transfer-Encoding: base64
 
-SSBhbSBvbiB2YWNhdGlvbiDwn4y0
\ No newline at end of file
+8J+MtCBJIGFtIG9uIHZhY2F0aW9uIPCfjLQ=
\ No newline at end of file