I'm using drupal_http_request() in linkchecker module to verify links. Today I debugged an issue where the UPDATE to MySQL fails. After some investigation it turned out that the error message is not UTF8 encoded and therefore the UPDATE fails.
RAW error message:
Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht ordnungsgem�� reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat.
UTF8 encoded error message:
Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht ordnungsgemäß reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat.
As you can see there are two special German letters inside that are not properly encoded.
I tried to do a $response->error = drupal_convert_to_utf8($response->error);
in linkchecker module and now it seems working, but expect this is not the right way as drupal_convert_to_utf8()
requires a second parameter with the source encoding.
I'm not yet sure if the error message is from my local German machine or the remote host!? Are we able to solve this encoding issue inside drupal_http_request()?
Comment | File | Size | Author |
---|---|---|---|
#8 | 371495_drupal_http_request_UTF8_bug.patch | 1.7 KB | hass |
Comments
Comment #1
c960657 CreditAttribution: c960657 commentedWeird. I think the message is generated by fsockopen(), but I wonder why PHP speaks German. Is setlocale() called anywhere? Are you using Windows? What is the output of
setlocale(LC_ALL, 0)
?Comment #2
hass CreditAttribution: hass commentedIt returns a
C
. I'm not using setlocale() myself anywhere... but DEVEL does... it may have been enabled when I have had the issues... cannot remember, but the chances are good. What should thisC
tell me?devel.module line 771:
Comment #3
c960657 CreditAttribution: c960657 commentedC
is good (the C locale is a minimal English locale),de_DE
or similar is bad. The existence ofsetlocale(LC_MESSAGES, 'de_DE')
somewhere would explain the problem. Otherwise I don't know.Comment #4
hass CreditAttribution: hass commentedbumping
Comment #5
hass CreditAttribution: hass commentedCode wise it looks like http://drupal.org/project/httprl has implemented a fix for this bug in
httprl_request()
...But drupal_convert_to_utf8() is better.
Comment #6
hass CreditAttribution: hass commentedComment #7
xjmI don't believe this meets the criteria for a major bug.
Comment #8
hass CreditAttribution: hass commentedPatch attached is based on last code level of HTTPRL module.
Comment #10
hass CreditAttribution: hass commentedComment #11
hass CreditAttribution: hass commented#8: 371495_drupal_http_request_UTF8_bug.patch queued for re-testing.
Comment #12
sunSounds like a duplicate of #1561214: Bootstrap sets C locale, but does not set UTF-8 character encoding
See also #614124: Bootstrap should reset locale settings
Feel free to re-open this issue, if I'm mistaken.