Opened 7 years ago

Closed 5 years ago

Last modified 5 years ago

#1483839 closed Feature Patches (duplicate)

Message subject and body should default to ISO-8859-1 when there is no Content-Type

Reported by: e-t172 Owned by:
Priority: 5 Milestone: 0.1-beta2
Component: IMAP connection Version:
Severity: major Keywords: charset encoding iso-8859-1 utf-8 content-type headers
Cc:

Description

(I am french, sorry for my bad english)

A lot of "not well-coded sites" send mails with no Content-Type header. In this case, RoundCube should display the message body and subject as ISO-8859-1 instead of UTF-8 to avoid encoding surprises.

I made a patch :

--- program/include/rcube_imap.inc.old  2006-05-18 17:53:06.000000000 +0200
+++ program/include/rcube_imap.inc      2006-06-14 01:48:56.000000000 +0200
@@ -1716,8 +1716,9 @@

       return $out;
       }
-    else
-      return $input;
+
+    // no encoding information, defaults to ISO-8859-1
+    return rcube_charset_convert($input, 'ISO-8859-1');
     }


@@ -1792,8 +1793,9 @@
     {
     if (is_array($ctype_param) && !empty($ctype_param['charset']))
       return rcube_charset_convert($body, $ctype_param['charset']);
-
-    return $body;
+
+    // defaults to ISO-8859-1
+    return rcube_charset_convert($body, 'ISO-8859-1');
     }

Attachments (2)

index.php.diff (371 bytes) - added by lancey 7 years ago.
Patch to support per-language default enconding
rcube_imap.inc.diff (2.1 KB) - added by lancey 5 years ago.
Patch to support per-language default enconding (updated to latest svn)

Download all attachments as: .zip

Change History (13)

comment:1 Changed 7 years ago by e-t172

  • Type changed from Bugs to Patches

Ooops, wrong category.

comment:2 Changed 7 years ago by thomasb

  • Milestone set to 0.1-beta2
  • Resolution set to fixed
  • Status changed from new to closed

Added to SVN trunk

comment:3 Changed 7 years ago by ericliang

  • Resolution fixed deleted
  • Status changed from closed to reopened

If I understand this ticket and new behaviour correctly then...

This is not correct. Why should there be assumed that default charset is ISO-8859-1 for everyone? This should at least be configurable by the admin since not everyone uses ISO-8859-1 charset!

Please correct this if you can and expect that defaulting ISO-8859-1 to RC will create problems with installations in other countries and languages.

Thank you in advance.

comment:4 Changed 7 years ago by patrys

It would be better to use iconv without specifying the input encoding to convert it to utf-8.

comment:5 Changed 7 years ago by lancey

Sadly, receiving mail without contect-type headers happens a lot. But i do think it should fall back to an encoding defined in the language file, not the ISO-8859-1 one. Messages in bulgarian cp-1251 look in ISO-8859-1 as ugly as in UTF-8 :) iconv is also not as good in guessing character maps as well as humans are.

I think the right way is to define a label in labels.inc like that:
$labelsdefaulteconding? = 'windows-1251';

and then use it in rcube_imap.inc, defaulting to ISO-8859-1 if no encoding defined in the current localization labels.inc like this:

return rcube_charset_convert($body, ($labelsdefaulteconding??$labelsdefaulteconding?:'ISO-8859-1'));

I could make a patch if you accept this proposal.

comment:6 Changed 7 years ago by lancey

And something more - this patch does not at all deal with messages' subjects and senders/receivers names - if they are improperly encoded, we should also convert them.

I'm working on this right now and will release some patch soon.

Changed 7 years ago by lancey

Patch to support per-language default enconding

comment:7 Changed 7 years ago by lancey

  • Resolution set to worksforme
  • Status changed from reopened to closed

I've uploaded two patches, which realise my idea - set the default encoding per language.

You have to add:
$labels['defaultencoding' = "windows-1251";
to the language labels file.

I don't know if we have a routine where we initialize things, the fix to index.php might need to go somewhere else - sorry if improper.

comment:8 Changed 7 years ago by lancey

A fix to rcube_imap.inc, the default encoding didn't fall back correctly to ISO-8859-1 if not specified in the labels.inc

comment:9 Changed 5 years ago by lancey

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Anyone willing to discuss on this or add it to svn?

Changed 5 years ago by lancey

Patch to support per-language default enconding (updated to latest svn)

comment:11 Changed 5 years ago by thomasb

  • Resolution set to duplicate
  • Status changed from reopened to closed

Configurable default charset: #1484730

Note: See TracTickets for help on using tickets.