From 7045bb9c07d31b6de5f2578d9a9f9971fc39f1cf Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 28 Jun 2013 04:15:28 -0400
Subject: [PATCH] Fix parsing one-line FETCH response, e.g. "* 1 FETCH (UID 9844 BODY[2.4] NIL)"
---
program/lib/Roundcube/rcube_imap_generic.php | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php
index 2bf199c..1928c70 100644
--- a/program/lib/Roundcube/rcube_imap_generic.php
+++ b/program/lib/Roundcube/rcube_imap_generic.php
@@ -2506,11 +2506,13 @@
// handle one line response
if ($line[0] == '(' && substr($line, -1) == ')') {
// tokenize content inside brackets
+ // the content can be e.g.: (UID 9844 BODY[2.4] NIL)
$tokens = $this->tokenizeResponse(preg_replace('/(^\(|\)$)/', '', $line));
for ($i=0; $i<count($tokens); $i+=2) {
if (preg_match('/^(BODY|BINARY)/i', $tokens[$i])) {
- $result = $tokens[$i+1];
+ $i += 2; // skip BODY|BINARY and part number
+ $result = $tokens[$i];
$found = true;
break;
}
@@ -3492,7 +3494,7 @@
break 2;
}
- // excluded chars: SP, CTL, ), [, ]
+ // excluded chars: SP, CTL, ), [, ], DEL
if (preg_match('/^([^\x00-\x20\x29\x5B\x5D\x7F]+)/', $str, $m)) {
$result[] = $m[1] == 'NIL' ? NULL : $m[1];
$str = substr($str, strlen($m[1]));
--
Gitblit v1.9.1