2.10.10: Subject garbled on creating new message in Cyrillic

Discuss, research, share, find, and solve bugs

2.10.10: Subject garbled on creating new message in Cyrillic

Postby samota » 11:14pm, Wed 26 Aug, 2009

When I create a new message to be sent, my subject gets all garbled after I save the message. Upon testing, the email arrives with subject also garbled. Both subject and email body are Cyrillic. Email body seems to be fine when creating and in test emails, but it is the subject that causes problems. Before, I had to run a find-replace on the phplist code to replace latin encoding with utf-8 everywhere. Worked great for 7 months, but now after upgrade I am facing same problem.
samota
phpList newbie
 
Posts: 4
Joined: 10:58pm, Wed 26 Aug, 2009

Re: Subject is garbled after creating new message in Cyrillic

Postby samota » 11:36pm, Wed 26 Aug, 2009

This seems to be resolved when editing admin/send_core line 1034
from: //value="'.htmlentities(iconv('ISO-8859-1','UTF-8',$subject),ENT_QUOTES,'UTF-8').'" size=40></td></tr>
to: value="'.htmlentities(iconv('UTF-8','UTF-8',$subject),ENT_QUOTES,'UTF-8').'" size=40></td></tr>

is this a bug?
samota
phpList newbie
 
Posts: 4
Joined: 10:58pm, Wed 26 Aug, 2009

Re: Subject is garbled after creating new message in Cyrillic

Postby H2B2 » 3:51am, Fri 28 Aug, 2009

I would say yes, it is a bug. It seems it was introduced when trying to fix issue http://mantis.phplist.com/view.php?id=15241 with the iconv() function.

I expect the developers will at some point have to review the code with respect to charset encoding, and hopefully remove all traces of hardcoded charsets.

See also:
viewtopic.php?f=17&t=24646
http://mantis.phplist.com/view.php?id=15324
http://mantis.phplist.com/view.php?id=1644
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Re: 2.10.10: Subject garbled on creating new message in Cyrillic

Postby H2B2 » 4:53pm, Tue 01 Sep, 2009

lwc suggests the following fix in this bug tracker entry: http://mantis.phplist.com/view.php?id=15324
lwc wrote:The problem is in public_html/lists/admin/send_core.php:

iconv('ISO-8859-1','UTF-8',$subject) and htmlentities(iconv('ISO-8859-1','UTF-8',$from) - those statements assume one uses ISO-8859-1, which is why you only get bug reports from people using other languages...

Note those statements were only added in recent versions. For example, v2.10.7 didn't have them and thus had no problems.

Here's the fix:

Code: Select all
// custom code - start
  $utf8_subject = $subject;
  $utf8_from = $from;
  if (strcasecmp($GLOBALS['strCharSet'], 'utf-8') <> 0) {
     $utf8_subject = iconv($GLOBALS['strCharSet'],'UTF-8',$utf8_subject);
     $utf8_from = iconv($GLOBALS['strCharSet'],'UTF-8',$utf8_from);
  }

  $maincontent .= '
  <tr><td>'.Help("subject").' '.$GLOBALS['I18N']->get("Subject").':</td>
    <td><input type=text name="msgsubject"
    //value="'.htmlentities($utf8_subject,ENT_QUOTES,'UTF-8').'" size=40></td></tr>
  <tr>
    <td colspan=2>
    </td></tr>
  <tr><td>'.Help("from").' '.$GLOBALS['I18N']->get("fromline").':</td>
    <td><input type=text name=from
    value="'.htmlentities($utf8_from,ENT_QUOTES,'UTF-8').'" size=40></td></tr>
  <tr><td colspan=2>

  </td></tr>';
// custom code - end


The "//" in "//value" shows up in the HTML code. See bug report 0015323


The attached lists/admin/send_core.php file was provided by lwc, and includes the above fix as well as the fix for issue 001523:
Attachments
send_core.zip
patched file: lists/admin/send_core.php
Includes fix for issues 0015324 and 0015323
(16.22 KiB) Downloaded 1032 times
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Re: 2.10.10: Subject garbled on creating new message in Cyrillic

Postby endjo » 9:53am, Wed 02 Sep, 2009

Very useful, thanks for this post.
endjo
PL Nut
 
Posts: 18
Joined: 6:52pm, Mon 31 Aug, 2009

Re: 2.10.10: Subject garbled on creating new message in Cyrillic

Postby veptune » 10:40am, Thu 12 Nov, 2009

Hello,

I updated the file. But i still get the problem after i click on "save", the subject is garbled

When i receive the email, the subject is ok, this is just a bug on the input box on the form.

Any suggestions ?

thanks
veptune
phpList newbie
 
Posts: 2
Joined: 5:29pm, Mon 26 Oct, 2009

Re: 2.10.10: Subject garbled on creating new message in Cyrillic

Postby clotilde » 2:57pm, Tue 01 Dec, 2009

Thank you very much for sharing this patch.

I'm with Veptune, though: it successfully fixes the problem in the email that's sent out (now with the correct character encoding), but in the interface, the subject is still displayed with garbled special characters (in my case, French accented characters).

It's not a show-stopper, to be sure, but it is still not the most pleasant experience when editing a message.

Could anyone suggest a fix for this?

Many thanks,
Clotilde.
clotilde
phpList newbie
 
Posts: 2
Joined: 4:57pm, Sat 02 Feb, 2008

Re: 2.10.10: Subject garbled on creating new message in Cyrillic

Postby Tondeuse » 1:27am, Wed 03 Mar, 2010

Excellent , Excellent work, this indeed does the trick for phplist administrators who do not send in English and insist on preserving a utf-8 workflow. I have often had headaches with character encoding issues in PHPlist, thanks to this post, I did not spend days trying to work out half assed solution. This simply works and the coding is done right. Thanks a lot to the author.

I should mention that I still have issues with the display of messages extracted from the database in the admin module (message title, footer, etc...), but it is not quite as crucial.

Thanks so much again.
Tondeuse
phpList newbie
 
Posts: 1
Joined: 1:21am, Wed 03 Mar, 2010


Return to Bug Discussion

Who is online

Users browsing this forum: No registered users and 1 guest