From 6930fe66a802a73e4aaf2f9e573924d99cae7d0f Mon Sep 17 00:00:00 2001 From: SJ Date: Sat, 23 Mar 2013 19:14:36 +0100 Subject: [PATCH] workaround for weird mime name encoding by evolution --- webui/model/search/message.php | 3 ++- webui/system/misc.php | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/webui/model/search/message.php b/webui/model/search/message.php index 7573983f..9d896782 100644 --- a/webui/model/search/message.php +++ b/webui/model/search/message.php @@ -453,7 +453,7 @@ class ModelSearchMessage extends Model { $attachment = $this->get_attachment($query->row['piler_id'], $query->row['attachment_id']); - return array('filename' => $query->row['name'], 'piler_id' => $query->row['piler_id'], 'attachment' => $attachment); + return array('filename' => fix_evolution_mime_name_crap($query->row['name']), 'piler_id' => $query->row['piler_id'], 'attachment' => $attachment); } } @@ -471,6 +471,7 @@ class ModelSearchMessage extends Model { if(!isset($query->rows)) { return array(); } foreach($query->rows as $q) { + $q['name'] = fix_evolution_mime_name_crap($q['name']); array_push($data, $q); } diff --git a/webui/system/misc.php b/webui/system/misc.php index 69de7995..b0cdb1ae 100644 --- a/webui/system/misc.php +++ b/webui/system/misc.php @@ -474,4 +474,14 @@ function convert_days_ymd($convert) { } +function fix_evolution_mime_name_crap($s = '') { + if(preg_match("/iso\-\d{1,4}\-\d{1,}\'\'/i", $s)) { + $s = preg_replace("/iso\-\d{1,4}\-\d{1,}\'\'/i", "", $s); + $s = utf8_encode(urldecode($s)); + } + + return $s; +} + + ?>