diff options
Diffstat (limited to 'program/lib')
-rw-r--r-- | program/lib/html2text.php | 6 | ||||
-rw-r--r-- | program/lib/imap.inc | 41 | ||||
-rw-r--r-- | program/lib/tnef_decoder.inc | 10 |
3 files changed, 43 insertions, 14 deletions
diff --git a/program/lib/html2text.php b/program/lib/html2text.php index e78ea10a9..dbf0943d5 100644 --- a/program/lib/html2text.php +++ b/program/lib/html2text.php @@ -522,9 +522,9 @@ class html2text $this->_link_count++; $this->_link_list .= "[" . $this->_link_count . "] $link\n"; $additional = ' [' . $this->_link_count . ']'; - } elseif ( substr($link, 0, 11) == 'javascript:' ) { - // Don't count the link; ignore it - $additional = ''; + } elseif ( substr($link, 0, 11) == 'javascript:' ) { + // Don't count the link; ignore it + $additional = ''; // what about href="#anchor" ? } else { $this->_link_count++; diff --git a/program/lib/imap.inc b/program/lib/imap.inc index 67a2b7b3c..995d82fb6 100644 --- a/program/lib/imap.inc +++ b/program/lib/imap.inc @@ -335,6 +335,7 @@ function iil_StartsWithI($string, $match, $bye=false) { } if ($bye && strncmp($string, '* BYE ', 6) == 0) { return true; + } return false; } @@ -383,6 +384,12 @@ function iil_C_GetCapability(&$conn, $name) return false; } +function iil_C_ClearCapability(&$conn) +{ + $conn->capability = array(); + $conn->capability_readed = false; +} + function iil_C_Authenticate(&$conn, $user, $pass, $encChallenge) { $ipad = ''; @@ -564,7 +571,7 @@ function iil_Connect($host, $user, $password, $options=null) { $result = false; - //initialize connection + // initialize connection $conn = new iilConnection; $conn->error = ''; $conn->errorNum = 0; @@ -598,16 +605,15 @@ function iil_Connect($host, $user, $password, $options=null) { $iil_errornum = -1; return false; } + if (!$ICL_PORT) { $ICL_PORT = 143; } - //check for SSL - if ($ICL_SSL) { + if ($ICL_SSL && $ICL_SSL != 'tls') { $host = $ICL_SSL . '://' . $host; } - - //open socket connection + $conn->fp = fsockopen($host, $ICL_PORT, $errno, $errstr, 10); if (!$conn->fp) { $iil_error = "Could not connect to $host at port $ICL_PORT: $errstr"; @@ -625,6 +631,29 @@ function iil_Connect($host, $user, $password, $options=null) { $conn->message .= $line; + // TLS connection + if ($ICL_SSL == 'tls' && iil_C_GetCapability($conn, 'STARTTLS')) { + if (version_compare(PHP_VERSION, '5.1.0', '>=')) { + iil_PutLine($conn->fp, 'stls000 STARTTLS'); + + $line = iil_ReadLine($conn->fp, 4096); + if (!iil_StartsWith($line, 'stls000 OK')) { + $iil_error = "Server responded to STARTTLS with: $line"; + $iil_errornum = -2; + return false; + } + + if (!stream_socket_enable_crypto($conn->fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { + $iil_error = "Unable to negotiate TLS"; + $iil_errornum = -2; + return false; + } + + // Now we're authenticated, capabilities need to be reread + iil_C_ClearCapability($conn); + } + } + if (strcasecmp($auth_method, "check") == 0) { //check for supported auth methods if (iil_C_GetCapability($conn, 'AUTH=CRAM-MD5') || iil_C_GetCapability($conn, 'AUTH=CRAM_MD5')) { @@ -2433,7 +2462,7 @@ function iil_C_FetchMIMEHeaders(&$conn, $mailbox, $id, $parts) { // format request foreach($parts as $part) - $peeks[] = "BODY[$part.MIME]"; + $peeks[] = "BODY.PEEK[$part.MIME]"; $request = "$key FETCH $id (" . implode(' ', $peeks) . ')'; diff --git a/program/lib/tnef_decoder.inc b/program/lib/tnef_decoder.inc index f9b7c3684..8e3682a9b 100644 --- a/program/lib/tnef_decoder.inc +++ b/program/lib/tnef_decoder.inc @@ -102,7 +102,7 @@ function tnef_geti32(&$buf) function tnef_decode_attribute($attribute, &$buf) { - global $debug, $download; + global $debug; $length = tnef_geti32($buf); $value = tnef_getx($length, $buf); //data @@ -116,9 +116,9 @@ function tnef_decode_attribute($attribute, &$buf) switch($attribute) { case TNEF_BODYTEXT: - if (!$download) + if ($debug) { - printf("<b>Embedded message:</b><pre>%s</pre>",$value); + printf("<b>Embedded message:</b><pre>%s</pre>", $value); } break; @@ -195,7 +195,7 @@ function extract_mapi_attrs($buf, &$attachment_data) case TNEF_MAPI_ATTACH_DATA: tnef_getx(16, $value); // skip the next 16 bytes (unknown data) - array_shift($attachment_data); // eliminate the current (bogus) attachment + array_shift($attachment_data); // eliminate the current (bogus) attachment do_tnef_decode($value, $attachment_data); // recursively process the attached message break; @@ -349,4 +349,4 @@ function tnef_decode($buf) } -?>
\ No newline at end of file +?> |