diff options
author | alecpl <alec@alec.pl> | 2008-06-03 12:23:55 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2008-06-03 12:23:55 +0000 |
commit | 02548b976c092f0e2b8680627adbc04303ff5d67 (patch) | |
tree | f273ff857bcce376f554bc115926a47b299c92e4 /program/lib/imap.inc | |
parent | e47aadcd99b1d9f0ab46dfc261232215f669f3c7 (diff) |
- 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()
Diffstat (limited to 'program/lib/imap.inc')
-rw-r--r-- | program/lib/imap.inc | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/program/lib/imap.inc b/program/lib/imap.inc index 4aefbb6de..0f3ac98f1 100644 --- a/program/lib/imap.inc +++ b/program/lib/imap.inc @@ -57,6 +57,9 @@ - trim(chop()) replaced by trim() - added iil_Escape() with support for " and \ in folder names - 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) { return $line; } + + if (!$size) { + $size = 1024; + } + do { - // FIXME: hardcode size? - $buffer = fgets($fp, 2048); + $buffer = fgets($fp, $size); if ($buffer === false) { break; } @@ -190,8 +197,8 @@ function iil_MultLine($fp, $line) { preg_match_all('/(.*)\{([0-9]+)\}$/', $line, $a); $bytes = $a[2][0]; while (strlen($out) < $bytes) { - $line = iil_ReadLine($fp, 1024); - $out .= chop($line); + $line = iil_ReadBytes($fp, $bytes); + $out .= $line; } $line = $a[1][0] . "\"$out\""; } @@ -2550,33 +2557,18 @@ function iil_C_AppendFromFile(&$conn, $folder, $path) { function iil_C_FetchStructureString(&$conn, $folder, $id) { $fp = $conn->fp; $result = false; + if (iil_C_Select($conn, $folder)) { $key = 'F1247'; if (fputs($fp, "$key FETCH $id (BODYSTRUCTURE)\r\n")) { do { - $line=chop(iil_ReadLine($fp, 5000)); - if ($line[0] == '*') { - if (ereg("\}$", $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); - } + $line = iil_ReadLine($fp, 5000); + $line = iil_MultLine($fp, $line); + $result .= $line; } while (!preg_match("/^$key/", $line)); + + $result = trim(substr($result, strpos($result, 'BODYSTRUCTURE')+13, -(strlen($result)-strrpos($result, ')')-1))); } } return $result; |