From 7060c7f0cca420c7458dcc63db898722ca4a11a0 Mon Sep 17 00:00:00 2001 From: stekkel Date: Wed, 28 May 2003 22:08:07 +0000 Subject: [PATCH] Here we go again, another try to fix folding of headerlines with encoded addresses git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4947 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- class/deliver/Deliver.class.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/class/deliver/Deliver.class.php b/class/deliver/Deliver.class.php index abd24c09..3de308f1 100644 --- a/class/deliver/Deliver.class.php +++ b/class/deliver/Deliver.class.php @@ -369,7 +369,6 @@ class Deliver { default: $hdr_s .= $this->foldLine($header[$i], 78, str_pad('',4)); break; } } - $header = $hdr_s; $header .= $rn; /* One blank line to separate header and body */ $raw_length += strlen($header); @@ -390,15 +389,20 @@ class Deliver { while (strlen($line) > $length) { $fold = false; /* handle encoded parts */ - if (preg_match('/(=\?([^?]*)\?(Q|B)\?([^?]*)\?=)(.*)/Ui',$line,$regs)) { + if (preg_match('/(=\?([^?]*)\?(Q|B)\?([^?]*)\?=)(\s+|.*)/Ui',$line,$regs)) { $fold_tmp = $regs[1]; + if (!trim($regs[5])) { + $fold_tmp .= $regs[5]; + } $iPosEnc = strpos($line,$fold_tmp); $iLengthEnc = strlen($fold_tmp); $iPosEncEnd = $iPosEnc+$iLengthEnc; if ($iPosEnc < $length && (($iPosEncEnd) > $length)) { $fold = true; /* fold just before the start of the encoded string */ - $aFoldLine[] = substr($line,0,$iPosEnc); + if ($iPosEnc) { + $aFoldLine[] = substr($line,0,$iPosEnc); + } $line = substr($line,$iPosEnc); if (!$bFirstFold) { $bFirstFold = true; @@ -416,8 +420,8 @@ class Deliver { $sLineRem = substr($line,$iPosEncEnd,$length - $iPosEncEnd); if (preg_match('/^(=\?([^?]*)\?(Q|B)\?([^?]*)\?=)(.*)/Ui',$sLineRem) || !preg_match('/[=,;\s]/',$sLineRem)) { /*impossible to fold clean in the next part -> fold after the enc string */ - $aFoldLine[] = substr($line,0,$iPosEncEnd+1); - $line = substr($line,$iPosEncEnd+1); + $aFoldLine[] = substr($line,0,$iPosEncEnd); + $line = substr($line,$iPosEncEnd); $fold = true; if (!$bFirstFold) { $bFirstFold = true; @@ -456,7 +460,6 @@ class Deliver { } $line = implode($fold_string,$aFoldLine); } - return $line."\r\n"; } -- 2.25.1