Make WordPress Core

Opened 17 years ago

Closed 17 years ago

#6788 closed defect (bug) (fixed)

wp-mail.php utf8 (umlauts)

Reported by: revolution48's profile revolution48 Owned by: filosofo's profile filosofo
Milestone: 2.7 Priority: normal
Severity: blocker Version: 2.5
Component: General Keywords: utf8, wp-mail.php, deutsch, umlaut, has-patch, needs-testing
Focuses: Cc:

Description

Wordpress version 2.5 wp-mail.php trims post-by-email content body at german umlauts. We can fix this by adding utf8_decode to wp-mail.php

Line 154

$content = utf8_encode($content);

That's all, folks.

Attachments (3)

wp-mail.php.patch (2.2 KB) - added by Laenny 17 years ago.
Patch using iconv to convert most encodings to utf8
wp-mail_swe_characters.zip (258 bytes) - added by DaMsT 17 years ago.
Swedish characters for filosofo to work with
wp-mail.iconv.diff (8.5 KB) - added by filosofo 17 years ago.

Download all attachments as: .zip

Change History (18)

#1 @revolution48
17 years ago

Problem:
Wordpress version 2.5 wp-mail.php cuts off subjects and content containing german umlauts.

Solution:
We can fix this by adding utf8_decode to wp-mail.php

Add this code:

Line 65
$subject = utf8_encode($subject);

Line 154
$content = utf8_encode($content);

Status:
a FORUM entry has been made here http://wordpress.org/support/topic/170583

#2 @Laenny
17 years ago

A more general solution would be nicer, this one only works for ISO-8859-1 to UTF-8 conversion.
Most German Email programs use ISO-8859-1 by default, but since Wordpress does not have only have German users...
You proposed patch would break if UTF-8 encoding was used, for example.
I will try to find a nice, general solution using the iconv-Library.

For the subject I have done it by now:

Line 64:

old:

$subject = wp_iso_descrambler($subject);

new:

$subject = iconv_mime_decode($subject,2,'utf8');

(why reinvent the wheel?) - works like a charm with utf8 AND ISO-8859-1 subjects.

I will come back later and try to present a solution for the email body.

@Laenny
17 years ago

Patch using iconv to convert most encodings to utf8

#3 @Laenny
17 years ago

  • Keywords has-patch needs-testing added

added has-patch and needs-testing flags

#4 @ryan
17 years ago

  • Milestone changed from 2.5.2 to 2.9

Milestone 2.5.2 deleted

#5 @revolution48
17 years ago

Laenny's patch works fine if we also decode the body content. To do this add:

Line 76
$content = quoted_printable_decode($content);

#6 @DaMsT
17 years ago

Why is this moved time and time again? The Swedish community starting to get annoyed by this. Should be patched for 2.7. This is an easy one to patch!

#7 @DaMsT
17 years ago

  • Milestone changed from 2.9 to 2.7

#8 @filosofo
17 years ago

  • Owner changed from anonymous to filosofo

@DaMsT
17 years ago

Swedish characters for filosofo to work with

#9 @ryan
17 years ago

iconv isn't always available so we'll probably need some function_exists checks.

#10 follow-up: @westi
17 years ago

  • Cc westi added
  • Milestone changed from 2.7 to 2.8

Moved to 2.8 for now.

Patch very welcome but we need to ensure we cope with all mail encodings and don't break different ones instead.

#11 in reply to: ↑ 10 @DaMsT
17 years ago

Replying to westi:

Moved to 2.8 for now.

Patch very welcome but we need to ensure we cope with all mail encodings and don't break different ones instead.

You have to be freaking kidding med >:

#12 @DaMsT
17 years ago

  • Severity changed from major to blocker

#13 @filosofo
17 years ago

Patch wp-mail.iconv.diff seems to handle the character encoding issues in my tests.

#14 @westi
17 years ago

  • Milestone changed from 2.8 to 2.7

Patch looks good.

Rolling this into 2.7 :-)

#15 @westi
17 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [10011]) Improve wp-mail utf8 support. Fixes #6788 props filosofo.

Note: See TracTickets for help on using tickets.