Fix PostgreSQL UTF-8 encoding errors from IMAP email data #130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Scheduled email receiver was failing with
SQLSTATE[22021]: invalid byte sequence for encoding "UTF8": 0xc3 0x20when processing emails. IMAP data contains invalid UTF-8 sequences that PostgreSQL rejects.Changes
Added UTF-8 sanitization utilities (
ThreadUtils.php)sanitizeUtf8String()- replaces invalid byte sequences usingmb_convert_encoding()sanitizeUtf8Recursive()- handles nested arrays/objectsSanitize all text data before DB insertion (
ThreadEmailDatabaseSaver.php)Handles edge cases: empty strings, valid UTF-8 (including Norwegian characters), control characters, and the specific
0xc3 0x20sequence from the error.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/PHPMailer/PHPMailer/zipball/bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/laminas/laminas-loader/zipball/c507d5eccb969f7208434e3980680a1f6c0b1d8d/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/laminas/laminas-mail/zipball/110e04497395123998220e244cceecb167cc6dda/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/laminas/laminas-mime/zipball/08cc544778829b7d68d27a097885bd6e7130135e/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/laminas/laminas-servicemanager/zipball/a8640182b892b99767d54404d19c5c3b3699f79b/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/laminas/laminas-stdlib/zipball/8974a1213be42c3e2f70b2c27b17f910291ab2f4/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/laminas/laminas-validator/zipball/b3ec5865e7aa60a0fbce211500f4a5c6a6e11a30/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/myclabs/DeepCopy/zipball/1720ddd719e16cf0db4eb1c6eca108031636d46c/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/nikic/PHP-Parser/zipball/ae59794362fe85e051a58ad36b289443f57be7a9/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/c34583b87e7b7a8055bf6c450c2c77ce32a24084/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/comparator/zipball/a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/diff/zipball/c41e007b4b62af48218231d6c2275e4c9b975b2e/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/environment/zipball/8074dbcd93529b357029f5cc5058fd3e43666984/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/exporter/zipball/955288482d97c19a372d3f31006ab3f37da47adf/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/global-state/zipball/987bafff24ecc4c9ac418cab1145b96dd6e9cbd9/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7e308268858ed6baedc8704a304727d20bc07c77/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8080be387a5be380dda48c6f41cee4a13aadab3d/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/05909fb5bc7df4c52992396d0116aed689f93712/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/9614ac4d8061dc257ecc64cba1b140873dce8ad3/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/8d2DYS /usr/bin/composer install --no-interaction(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.