Ticket #1485050 (closed Patches: fixed)

Opened 4 months ago

Last modified 4 months ago

Improved using configurable default charset for message decoding (update for Changeset 1195)

Reported by: Javer Owned by:
Priority: 2 Milestone: 0.2-alpha
Component: PHP backend Version: svn-trunk
Severity: major Keywords:
Cc:

Description

Here is the patch, which allow to display correctly messages headers fields like From, To, Subject, which does not contain inline specified charset (like =?charset?...?=), but contains native language symbols. Also default fallback charset in decode_mime_string() was replaced by configurable default_charset to use specified regional charset instead of ISO-8859-1 whenever it was used in the code. This greatly improve support of native languages.

Attachments

charset-fix.diff (3.8 kB) - added by Javer 4 months ago.
rcube_imap_2.diff (0.6 kB) - added by Javer 4 months ago.
Patch for solution #2.

Change History

Changed 4 months ago by Javer

Changed 4 months ago by Javer

Look on raw diff file, html representation does not contain changes in program/steps/mail/show.inc file (why?)

Changed 4 months ago by alec

  • status changed from new to closed
  • resolution set to fixed

Patch applied in r1366 with small difference. We should not use config global inside rcube_imap library.

Changed 4 months ago by Javer

  • status changed from closed to reopened
  • resolution deleted

Replacing $GLOBALS[ 'CONFIG' ][ 'default_charset' ] with $this->default_charset cause Fatal error on PHP5, because decode_mime_string() method called statically and $this is undefined in this case.

PHP Fatal error:  Using $this when not in object context in /.../program/include rcube_imap.php on line 2366

Possible solutions:
1. Use $GLOBALS[ 'CONFIG' ][ 'default_charset' ] (why not, this is not third-party library ?).
2. Use $IMAP->default_charset until class not fully rewritten in PHP5 and this property still public, or leave him public also in the future. See patch rcube_imap_2.diff. Here can be potential bug (see solution 4).
3. Add static property rcube_imap::$config_default_charset in rcube_imap class and fill him with specified in config value while initializing class instance.
4. Create global variable $DEFAULT_CHARSET and use them whenever it needed, because theoretically decode_mime_string() can be called without/before creating instance of rcube_imap class and it will cause fatal error.

Changed 4 months ago by Javer

Patch for solution #2.

Changed 4 months ago by alec

I don't understand. Decode_mime_string() is part of rcube_imap class, so cannot be called outside the class.

Changed 4 months ago by Javer

rcube_imap::decode_mime_string() - call of static method of rcube_imap class, can be called without creating instance of the class. When called static method, it is not necessary to create instance of a class, therefore object really does not exists and not accessible, "$this" is undefined inside method, but defined "self", which is equal to class name. Anybody can call static method decode_mime_string() outside of the class rcube_imap, and we have many examples of this also in the source of RoundCube.
What I mean about potential bug in solution 2: if anybody call this method before creating instance of a class, global variable $IMAP will be NULL and construction $IMAP->default_charset will cause fatal error.

Changed 4 months ago by Javer

But because using of rcube_imap::decode_mime_string() are light controlled by developers, i recommend to use solution 2 and patch rcube_imap_2.diff, which now resolve problem with fatal error, which present in svn-trunk.

Changed 4 months ago by alec

  • status changed from reopened to closed
  • resolution set to fixed

I choose gate number one ;) Fixed in r1367. I understand what you're writing, but I have no fatal errors with $this in my logs.

Note: See TracTickets for help on using tickets.