0

I keep receiving e-mails that are so badly constructed by such incompetent people that it somehow bypasses the PHP check using mb_check_encoding, and thus proceeds to the PostgreSQL INSERT query, which keeps logging this kind of stupid nonsense:

pg_query_params(): Query failed: ERROR:  invalid byte sequence for encoding "UTF8": 0xe4 0x72 0x20:

This has been going on for years and has driven me nearly insane.

I can't use PG function hacks. This check must be done in PHP code.

How do I correctly detect if a string contains "invalid byte sequence" in PHP so that I can reject the e-mail as malformed (or "heal" it so that it contains "valid byte sequence")?

0 Answers0