UC_Ticket could not fetch correct email with unicode characters at subject. It returns something like: =?UTF-8?Q?_ho=E1=BA=B7c_v=E1=BB=81?= =?UTF-8?Q?_]_N=E1=BB=99i_dung_th=E1=BB=AD?=

Comments

Anonymous’s picture

Assigned: Unassigned »

Hmm, haven't seen this one yet. I'll try to reproduce it and see what's going on.

Nguyen DO’s picture

Ah, i am fetching emails from a Gmail account

mariano.barcia’s picture

Same thing happening to me. How to fix? Thanks.

mariano.barcia’s picture

Ok I fixed this by making use of the imap_mime_header_decode() function.

Will be testing it. Differences pasted inline here (sorry, don't have SSH access now).

***** C:\DOCUME~1\ADMINI~1\TEMP\SCP23687\PUBLIC_HTML\SITES\ALL\MODULES\UC_TICK
\uc_ticket.module
388: //first we look for ticket number in the subject
389: $subject_element = imap_mime_header_decode($header->subject);
390: $subject = $subject_element[0]->text;
391: preg_match_all('/\[T#([0-9]*)\]/', $subject, $matches);
***** C:\DOCUMENTS AND SETTINGS\ADMINISTRADOR\MIS DOCUMENTOS\DOWNLOADS\UC_TICK
-6.X-1.0-BETA6\UC_TICKET\UC_TICKET.MODULE
388: //first we look for ticket number in the subject
389: $subject = $header->subject;
390: preg_match_all('/\[T#([0-9]*)\]/', $subject, $matches);

***** C:\DOCUME~1\ADMINI~1\TEMP\SCP23687\PUBLIC_HTML\SITES\ALL\MODULES\UC_TICKE
\uc_ticket.module
427: //find out if we need to associate this ticket with an order
428: $subject_element = imap_mime_header_decode($header->subject);
429: $subject = $subject_element[0]->text;
430: preg_match_all('/\[O#([0-9]*)\]/', $subject, $matches);
***** C:\DOCUMENTS AND SETTINGS\ADMINISTRADOR\MIS DOCUMENTOS\DOWNLOADS\UC_TICKE
-6.X-1.0-BETA6\UC_TICKET\UC_TICKET.MODULE
426: //find out if we need to associate this ticket with an order
427: $subject = $header->subject;
428: preg_match_all('/\[O#([0-9]*)\]/', $subject, $matches);

***** C:\DOCUME~1\ADMINI~1\TEMP\SCP23687\PUBLIC_HTML\SITES\ALL\MODULES\UC_TICKE
\uc_ticket.module
476:
477: $subject_element = imap_mime_header_decode($header->subject);
478: $subject = $subject_element[0]->text;
479: $subject = preg_replace('`\[[^\]]*\]`', '', $subject);
480: if (is_array($header->from)) {
***** C:\DOCUMENTS AND SETTINGS\ADMINISTRADOR\MIS DOCUMENTOS\DOWNLOADS\UC_TICKE
-6.X-1.0-BETA6\UC_TICKET\UC_TICKET.MODULE
462:
463: $subject = preg_replace('`\[[^\]]*\]`', '', $header->subject);
464: if (is_array($header->from)) {
*****

Anonymous’s picture

Status: Active » Needs review

Excellent, I'll try out those changes. Thanks.

mariano.barcia’s picture

Did you get a chance to test this? Thanks.

tnfno’s picture

This fix works for the subject. I also have a problem that the email body is broken up at the first special character (like Norwegian æøå ÆØÅ).

tnfno’s picture

To answer my own question above: I fixed this by simply replacing everyting in function uc_ticket_get_body() with :

function uc_ticket_get_body($raw_body, $structure) {
  $body = imap_utf8($raw_body);
  return $body;
}

Probably not 100% correct, but it works for my Norwegian characters...

You also need to apply the other patch above to get UTF8 characters in the title.