patch from jvl xs4all nl

This commit is contained in:
Lars Kneschke 2006-01-16 11:14:33 +00:00
parent fac250e6e0
commit 40586d80db

View File

@ -1109,6 +1109,8 @@ class Horde_iCalendar {
/** /**
* Return the folded version of a line. * Return the folded version of a line.
* JVL rewritten to fold on any ; or: or = if present before column 75
* this is still rfc2445 section 4.1 compliant
*/ */
function _foldLine($line) function _foldLine($line)
{ {
@ -1117,13 +1119,19 @@ class Horde_iCalendar {
$foldedline = ''; $foldedline = '';
while (!empty($line)) { while (!empty($line)) {
$maxLine = substr($line, 0, 75); $maxLine = substr($line, 0, 75);
$cutPoint = max(60, max(strrpos($maxLine, ';'), strrpos($maxLine, ':')) + 1); $cutPoint = 1+max(is_numeric($p1 = strrpos($maxLine,';')) ? $p1 : -1,
is_numeric($p1 = strrpos($maxLine,':')) ? $p1 : -1,
is_numeric($p1 = strrpos($maxLine,'=')) ? $p1 : -1);
if ($cutPoint < 1) // nothing found, then fold complete maxLine
$cutPoint = 75;
// now fold [0..(cutPoint-1)]
$foldedline .= (empty($foldedline))
? substr($line, 0, $cutPoint)
: $this->_newline . ' ' . substr($line, 0, $cutPoint);
$foldedline .= (empty($foldedline)) ? $line = (strlen($line) <= $cutPoint)
substr($line, 0, $cutPoint) : ? ''
$this->_newline . ' ' . substr($line, 0, $cutPoint); : substr($line, $cutPoint);
$line = (strlen($line) <= $cutPoint) ? '' : substr($line, $cutPoint);
} }
return $foldedline; return $foldedline;
} }