Skip to content

Commit

Permalink
[mms] Workaround broken MIME parts that cannot be binary decoded on t…
Browse files Browse the repository at this point in the history
…he server.
  • Loading branch information
slusarz committed May 14, 2014
1 parent 57a3de2 commit bd9500e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
29 changes: 22 additions & 7 deletions framework/Imap_Client/lib/Horde/Imap/Client/Socket.php
Expand Up @@ -2593,11 +2593,26 @@ protected function _fetch(Horde_Imap_Client_Fetch_Results $results,
$results->get($sequence ? $k : $v->getUid())->merge($v);
}
} catch (Horde_Imap_Client_Exception_ServerResponse $e) {
// A NO response, when coupled with a sequence FETCH, most
// likely means that messages were expunged. RFC 2180 [4.1]
if ($sequence &&
($e->status === Horde_Imap_Client_Interaction_Server::NO)) {
$this->noop();
if ($e->status === Horde_Imap_Client_Interaction_Server::NO) {
if ($e->getCode() === $e::UNKNOWNCTE) {
/* UNKNOWN-CTE error. Redo the query without the BINARY
* elements. */
$bq = $pipeline->data['binaryquery'];

foreach ($queries as $val) {
foreach ($bq as $key2 => $val2) {
unset($val2['decode']);
$val['_query']->bodyPart($key2, $val2);
$val['_query']->remove(Horde_Imap_Client::FETCH_BODYPARTSIZE, $key2);
}
$pipeline->data['fetch_followup'][] = $val;
}
} elseif ($sequence) {
/* A NO response, when coupled with a sequence FETCH, most
* likely means that messages were expunged. (RFC 2180
* [4.1]) */
$this->noop();
}
}
} catch (Exception $e) {
// For any other error, ignore the Exception - fetch() is nice in
Expand Down Expand Up @@ -2703,7 +2718,7 @@ protected function _fetchCmd(
if (!empty($val['decode']) &&
$this->queryCapability('BINARY')) {
$main_cmd = 'BINARY';
$pipeline->data['binaryquery'] = $val;
$pipeline->data['binaryquery'][$key] = $val;
}
break;

Expand Down Expand Up @@ -2981,7 +2996,7 @@ protected function _parseFetch(
/* Dovecot bug (as of 2.2.12): binary fetch of body
* part may fail with NIL return if decoding failed on
* server. Try again with non-decoded body. */
$bq = $pipeline->data['binaryquery'];
$bq = $pipeline->data['binaryquery'][$tag];
unset($bq['decode']);

$query = new Horde_Imap_Client_Fetch_Query();
Expand Down
2 changes: 2 additions & 0 deletions framework/Imap_Client/package.xml
Expand Up @@ -21,6 +21,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Workaround broken MIME parts that cannot be binary decoded on the server.
* [jan] Add Hungarian translation (Andras Galos &lt;galosa@netinform.hu&gt;).
</notes>
<contents>
Expand Down Expand Up @@ -2387,6 +2388,7 @@
<date>2014-05-03</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Workaround broken MIME parts that cannot be binary decoded on the server.
* [jan] Add Hungarian translation (Andras Galos &lt;galosa@netinform.hu&gt;).
</notes>
</release>
Expand Down

0 comments on commit bd9500e

Please sign in to comment.