[wp-trac] [WordPress Trac] #21554: Problem with determining e-mail charset in wp-mail.php
WordPress Trac
wp-trac at lists.automattic.com
Sun Aug 12 11:06:52 UTC 2012
#21554: Problem with determining e-mail charset in wp-mail.php
---------------------------+-----------------------------
Reporter: mighty_mt | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Blog by Email | Version: 3.4.1
Severity: normal | Keywords: needs-patch
---------------------------+-----------------------------
In wp-mail.php the charset of the incoming e-mail message is determined on
line 77 by taking the string between the second "=" in the line and the
end of line/second ";" respectively.
'''The problem'''
If the header line in question looks like any of the following that method
is perfectly fine:
{{{
Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes
Content-Type: multipart/alternative;
}}}
However in messages sent from e.g. Gmail or Goolge Reader this header line
usually looks like this:
{{{
Content-Type: multipart/alternative; boundary=f46d044516dd9cd71f04c70e55e8
}}}
I this case "f46d044516dd9cd71f04c70e55e8" is determined as the charset
and the iconv function further down on line 187 returns false which causes
the post content to be emptied.
'''Suggested solution'''
I personally think that it is better to have the post published with an
"incorrect" charset than with no content at all.
Therefore I suggest that on line 76 in wp-mail.php...
{{{
if ( ! empty( $content_type[1] ) ) {
}}}
...is replaced by...
{{{
if ( ! empty( $content_type[1] ) && stripos( $content_type[1], 'charset' )
!== FALSE ) {
}}}
...in order to check if there is actually a charset definded.
Alternatively/additionally the return value of the iconv function on line
187 should be checked and the $content variable only modified if the
return value doesn't equal FALSE.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21554>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list