WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#6788 closed defect (bug) (fixed)

wp-mail.php utf8 (umlauts)

Reported by: revolution48 Owned by: 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 6 years ago.
Patch using iconv to convert most encodings to utf8
wp-mail_swe_characters.zip (258 bytes) - added by DaMsT 5 years ago.
Swedish characters for filosofo to work with
wp-mail.iconv.diff (8.5 KB) - added by filosofo 5 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 revolution486 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

comment:2 Laenny6 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.

Laenny6 years ago

Patch using iconv to convert most encodings to utf8

comment:3 Laenny6 years ago

  • Keywords has-patch needs-testing added

added has-patch and needs-testing flags

comment:4 ryan6 years ago

  • Milestone changed from 2.5.2 to 2.9

Milestone 2.5.2 deleted

comment:5 revolution486 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);

comment:6 DaMsT5 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!

comment:7 DaMsT5 years ago

  • Milestone changed from 2.9 to 2.7

comment:8 filosofo5 years ago

  • Owner changed from anonymous to filosofo

DaMsT5 years ago

Swedish characters for filosofo to work with

comment:9 ryan5 years ago

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

comment:10 follow-up: westi5 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.

comment:11 in reply to: ↑ 10 DaMsT5 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 >:

comment:12 DaMsT5 years ago

  • Severity changed from major to blocker

filosofo5 years ago

comment:13 filosofo5 years ago

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

comment:14 westi5 years ago

  • Milestone changed from 2.8 to 2.7

Patch looks good.

Rolling this into 2.7 :-)

comment:15 westi5 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.