diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-03-30 18:04:18 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-03-30 18:04:18 +0000 |
| commit | 015717f7444b3e591e4cbe2f84cfa88dbdcafc13 (patch) | |
| tree | 8e3e545cd9944411e7dbb21aa81fb83b4c3ba00c /roundcubemail/program/include | |
| parent | b0794aa94808eb9bc7110f3212439ca531031e2b (diff) | |
- Fix incorrect word wrapping in outgoing plaintext multibyte messages (#1485714)
- Fix double footer in HTML message with embedded images
git-svn-id: https://svn.roundcube.net/trunk@2368 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include')
| -rw-r--r-- | roundcubemail/program/include/rcube_shared.inc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/roundcubemail/program/include/rcube_shared.inc b/roundcubemail/program/include/rcube_shared.inc index f1cbb19c3..a05815800 100644 --- a/roundcubemail/program/include/rcube_shared.inc +++ b/roundcubemail/program/include/rcube_shared.inc @@ -405,6 +405,54 @@ function rc_strrpos($haystack, $needle, $offset=0) return strrpos($haystack, $needle, $offset); } +/** + * Wrapper function for wordwrap + */ +function rc_wordwrap($string, $width=75, $break="\n", $cut=false) +{ + if (!function_exists('mb_substr') || !function_exists('mb_strlen')) + return wordwrap($string, $width, $break, $cut); + + $para = explode($break, $string); + $string = ''; + while (count($para)) { + $list = explode(' ', array_shift($para)); + $len = 0; + while (count($list)) { + $line = array_shift($list); + $l = mb_strlen($line); + $newlen = $len + $l + ($len ? 1 : 0); + + if ($newlen <= $width) { + $string .= ($len ? ' ' : '').$line; + $len += ($len ? 1 : 0) + $l; + } else { + if ($l > $width) { + if ($cut) { + $start = 0; + while ($l) { + $str = mb_substr($line, $start, $width); + $strlen = mb_strlen($str); + $string .= ($len ? $break : '').$str; + $start += $strlen; + $l -= $strlen; + $len = $strlen; + } + } else { + $string .= ($len ? $break : '').$line; + if (count($list)) $string .= $break; + $len = 0; + } + } else { + $string .= $break.$line; + $len = $l; + } + } + } + if (count($para)) $string .= $break; + } + return $string; +} /** * Read a specific HTTP request header |
