X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fstrings.php;h=c232e6720e07e647e5ffc18d002994cd0701e68b;hb=86419c0b6313322da3972835c9f4727b720ece25;hp=c7c6060f4d2594bf1aa513f06d54583f0af9dc01;hpb=75efc2fd136a1c420b57ec84212d5befc722b913;p=squirrelmail.git diff --git a/functions/strings.php b/functions/strings.php index c7c6060f..c232e672 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -16,7 +16,7 @@ * SquirrelMail version number -- DO NOT CHANGE */ global $version; -$version = '1.2.7 [CVS]'; +$version = '1.3.0 [CVS-DEVEL]'; /** * Wraps text at $wrap characters @@ -64,11 +64,41 @@ function sqWordWrap(&$line, $wrap) { /* Go to the next line if we have more to process */ if ($i < count($words)) { - $line .= "\n" . $beginning_spaces; + $line .= "\n"; } } } +/** + * Does the opposite of sqWordWrap() + */ +function sqUnWordWrap(&$body) { + $lines = explode("\n", $body); + $body = ''; + $PreviousSpaces = ''; + $cnt = count($lines); + for ($i = 0; $i < $cnt; $i ++) { + preg_match("/^([\t >]*)([^\t >].*)?$/", $lines[$i], $regs); + $CurrentSpaces = $regs[1]; + if (isset($regs[2])) { + $CurrentRest = $regs[2]; + } + + if ($i == 0) { + $PreviousSpaces = $CurrentSpaces; + $body = $lines[$i]; + } else if (($PreviousSpaces == $CurrentSpaces) /* Do the beginnings match */ + && (strlen($lines[$i - 1]) > 65) /* Over 65 characters long */ + && strlen($CurrentRest)) { /* and there's a line to continue with */ + $body .= ' ' . $CurrentRest; + } else { + $body .= "\n" . $lines[$i]; + $PreviousSpaces = $CurrentSpaces; + } + } + $body .= "\n"; +} + /** * If $haystack is a full mailbox name and $needle is the mailbox * separator character, returns the last part of the mailbox name. @@ -153,7 +183,7 @@ function php_self () { function get_location () { global $PHP_SELF, $SERVER_NAME, $HTTP_HOST, $SERVER_PORT, - $HTTP_SERVER_VARS; + $HTTP_SERVER_VARS, $imap_server_type; /* Get the path, handle virtual directories */ $path = substr(php_self(), 0, strrpos(php_self(), '/')); @@ -196,6 +226,14 @@ function get_location () { } } + /* this is a workaround for the weird macosx caching that + causes Apache to return 16080 as the port number, which causes + SM to bail */ + + if ($imap_server_type == 'macosx' && $port == ':16080') { + $port = ''; + } + /* Fallback is to omit the server name and use a relative */ /* URI, although this is not RFC 2616 compliant. */ return ($host ? $proto . $host . $port . $path : $path);