By robertdouglass on
When mailhandler receives certiain mail messages during cron, certain queries (INSERT) against the PostgreSql database (version 8) go wrong due to UNICODE incompatibilities. I'll be honest, I'm not so swift when it comes to understanding encoding issues. Has anyone experienced this problem? Any suggestions for going about debugging?
Here are the error messages:
pg_query(): Query failed: ERROR: invalid byte sequence for encoding "UNICODE": 0xe96561 in /usr/local/apache/htdocs/includes/database.pgsql.inc on line 45.
warning: pg_query(): Query failed: ERROR: Unicode characters greater than or equal to 0x10000 are not supported in /usr/local/apache/htdocs/includes/database.pgsql.inc on line 45.
warning: pg_query(): Query failed: ERROR: invalid byte sequence for encoding "UNICODE": 0xe92048 in /usr/local/apache/htdocs/includes/database.pgsql.inc on line 45.Here are the headers from a typical mail that makes it crash:
From angelathomas@ispamalot.br Tue Apr 5 14:53:17 2005
Return-Path: <angelathomas@ispamalot.com.br>
Received: from www.ispamalot.com.br (smtp.ispamalot.com.br [200.221.11.147])
by mail.mywebsite.com (8.12.11/8.12.11) with ESMTP id j35IrEVW013688
for <news@mywebsite.com>; Tue, 5 Apr 2005 14:53:14 -0400
Received: from [64.110.93.76] by www.ispamalot.com.br with HTTP; Tue, 5 Apr 2005 15:34:26 -0300
Message-ID: <4252458600002D27@www.ispamalot.com.br>
Date: Tue, 5 Apr 2005 19:34:26 +0100
From: angelathomas@ispamalot.com.br
Subject: {Spam?} =?iso-8859-1?Q?I=20=20NEED=20=20YOUR=20=20URGENT=20=20ASSISTANCE=20=20PLS=2E?=
To: angelathomas@ispamalot.com.br
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-yoursite-MailScanner-Information: Please contact the ISP for more information
X-yoursite-MailScanner: Found to be clean
X-yoursite-MailScanner-SpamCheck: spam, SBL+XBL
X-MailScanner-From: angelathomas@ispamalot.com.br
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by mail.mywebsite.com id j35IrEVW013688
Status: O
X-UID: 305
Content-Length: 2986
X-Keywords:
Dearest One,
REQUEST TO BE MY GUARDIAN AND THEN HELP ME TO COME OVER TO YOUR
COUNTRY:
Good day and how are you today? I hope fine? I got your contact from internet,permit
me to inform you of my desire to ask you to be a guardian or foster parent
to me and then help me out in what I'm about to tell you.I'm Angela Thomas(19)
i,m the only daughter of Late Mr.& Mrs.Joseph Thomas. My father
was a very wealthy Oil Marchant here in Abuja, the capital of Nigeria. He
was poisoned to death by his business associates on one of their outings
on a business trip. My mother died when i was a baby.
Comments
New clues
Somehow the following mail snippet:
is turning into this by the time it gets to the query:
- Robert Douglass
-----
www.robshouse.net
www.webs4.com
I guess part of the problem
I guess part of the problem is that mailhandler does not convert the iso-8859-1 encoding that the mail has to utf-8.
--
If you have troubles with a particular contrib project, please consider filing a support request. Thanks. And, by the way, Drupal 4.6 will support PHP 5.
--
Drupal services
My Drupal services
Would you recommend...
mb_convert_encoding($str, "UTF-8", "iso-8859-1");?
- Robert Douglass
-----
www.robshouse.net
www.webs4.com
drupal_convert_to_utf8 is more portable
We now have a function for this in core (drupal_convert_to_utf8).
--
If you have a problem, please search before posting a question.
iconv required for drupal_convert_to-utf8
All:
A caveat about drupal_convert_to_utf8: it calls/requires the "iconv" library with PHP4 (iconv is built in to PHP5, but "iconv" is a compile option with PHP4).
My ISP hasn't got iconv ... and won't, they say, until CPANEL doesn't break with it (still don't QUITE understand why they say this is related).
I ended up ripping (commenting) out all calls to "drupal_convert_to_utf8" in the mailhandler module.
I saw the bit about "iconv" in the logs ... thank goodness the watchdog and log stuff is working pretty well.
Charlie
You could also have recode
You could also have recode or the mb_string extension.
--
Drupal services
My Drupal services
--
Drupal services
My Drupal services
You could try that. You
You could try that. You shoul dof course check that the encoding is actually iso-8859-1 (maybe that fucntion does that). For Drupal 4.6 there will be the drupal_convert_to_utf8() function and a patch to mailhandler would be welcome..
--
If you have troubles with a particular contrib project, please consider filing a support request. Thanks. And, by the way, Drupal 4.6 will support PHP 5.
--
Drupal services
My Drupal services