- imap.inc: Fixed iil_MultLine(): use iil_ReadBytes() instead of iil_ReadLine()

- imap.inc: Fixed iil_C_FetchStructureString() to handle many
  literal strings in response (#1484969)
- imap.inc: Removed hardcoded data size in iil_ReadLine()
release-0.6
alecpl 16 years ago
parent e47aadcd99
commit 02548b976c

@ -1,6 +1,13 @@
CHANGELOG RoundCube Webmail CHANGELOG RoundCube Webmail
--------------------------- ---------------------------
2008/06/03 (alec)
----------
- imap.inc: Fixed iil_MultLine(): use iil_ReadBytes() instead of iil_ReadLine()
- imap.inc: Fixed iil_C_FetchStructureString() to handle many
literal strings in response (#1484969)
- imap.inc: Removed hardcoded data size in iil_ReadLine()
2008/05/30 (alec) 2008/05/30 (alec)
---------- ----------
- Support for subfolders in default/protected folders (#1484665) - Support for subfolders in default/protected folders (#1484665)

@ -57,6 +57,9 @@
- trim(chop()) replaced by trim() - trim(chop()) replaced by trim()
- added iil_Escape() with support for " and \ in folder names - added iil_Escape() with support for " and \ in folder names
- support \ character in username in iil_C_Login() - support \ character in username in iil_C_Login()
- fixed iil_MultLine(): use iil_ReadBytes() instead of iil_ReadLine()
- fixed iil_C_FetchStructureString() to handle many literal strings in response
- removed hardcoded data size in iil_ReadLine()
********************************************************/ ********************************************************/
@ -171,9 +174,13 @@ function iil_ReadLine($fp, $size) {
if (!$fp) { if (!$fp) {
return $line; return $line;
} }
if (!$size) {
$size = 1024;
}
do { do {
// FIXME: hardcode size? $buffer = fgets($fp, $size);
$buffer = fgets($fp, 2048);
if ($buffer === false) { if ($buffer === false) {
break; break;
} }
@ -190,8 +197,8 @@ function iil_MultLine($fp, $line) {
preg_match_all('/(.*)\{([0-9]+)\}$/', $line, $a); preg_match_all('/(.*)\{([0-9]+)\}$/', $line, $a);
$bytes = $a[2][0]; $bytes = $a[2][0];
while (strlen($out) < $bytes) { while (strlen($out) < $bytes) {
$line = iil_ReadLine($fp, 1024); $line = iil_ReadBytes($fp, $bytes);
$out .= chop($line); $out .= $line;
} }
$line = $a[1][0] . "\"$out\""; $line = $a[1][0] . "\"$out\"";
} }
@ -2550,33 +2557,18 @@ function iil_C_AppendFromFile(&$conn, $folder, $path) {
function iil_C_FetchStructureString(&$conn, $folder, $id) { function iil_C_FetchStructureString(&$conn, $folder, $id) {
$fp = $conn->fp; $fp = $conn->fp;
$result = false; $result = false;
if (iil_C_Select($conn, $folder)) { if (iil_C_Select($conn, $folder)) {
$key = 'F1247'; $key = 'F1247';
if (fputs($fp, "$key FETCH $id (BODYSTRUCTURE)\r\n")) { if (fputs($fp, "$key FETCH $id (BODYSTRUCTURE)\r\n")) {
do { do {
$line=chop(iil_ReadLine($fp, 5000)); $line = iil_ReadLine($fp, 5000);
if ($line[0] == '*') { $line = iil_MultLine($fp, $line);
if (ereg("\}$", $line)) { $result .= $line;
preg_match('/(.+)\{([0-9]+)\}/', $line, $match);
$result = $match[1];
do {
$line = chop(iil_ReadLine($fp, 100));
if (!preg_match("/^$key/", $line)) {
$result .= $line;
} else {
$done = true;
}
} while (!$done);
} else {
$result = $line;
}
list($pre, $post) = explode('BODYSTRUCTURE ', $result);
//truncate last ')' and return
$result = substr($post, 0, strlen($post)-1);
}
} while (!preg_match("/^$key/", $line)); } while (!preg_match("/^$key/", $line));
$result = trim(substr($result, strpos($result, 'BODYSTRUCTURE')+13, -(strlen($result)-strrpos($result, ')')-1)));
} }
} }
return $result; return $result;

Loading…
Cancel
Save