protected function canonicalizeBody($string)
{
$len = strlen($string);
$canon = '';
$method = $this->bodyCanon == 'relaxed';
for ($i = 0; $i < $len; ++$i) {
if ($this->bodyCanonIgnoreStart > 0) {
--$this->bodyCanonIgnoreStart;
continue;
}
switch ($string[$i]) {
case "\r":
$this->bodyCanonLastChar = "\r";
break;
case "\n":
if ($this->bodyCanonLastChar == "\r") {
if ($method) {
$this->bodyCanonSpace = false;
}
if ($this->bodyCanonLine == '') {
++$this->bodyCanonEmptyCounter;
} else {
$this->bodyCanonLine = '';
$canon .= "\r\n";
}
} else {
// Wooops Error
// todo handle it but should never happen
}
break;
case ' ':
case "\t":
if ($method) {
$this->bodyCanonSpace = true;
break;
}
default:
if ($this->bodyCanonEmptyCounter > 0) {
$canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter);
$this->bodyCanonEmptyCounter = 0;
}
if ($this->bodyCanonSpace) {
$this->bodyCanonLine .= ' ';
$canon .= ' ';
$this->bodyCanonSpace = false;
}
$this->bodyCanonLine .= $string[$i];
$canon .= $string[$i];
}
}
$this->addToBodyHash($canon);
}
protected function canonicalizeBody($string) { if (!$this->peclLoaded) { return parent::canonicalizeBody($string); } if (false && $this->dropFirstLF === true) { if ($string[0] == "\r" && $string[1] == "\n") { $string = substr($string, 2); } } $this->dropFirstLF = false; if (strlen($string)) { $this->dkimHandler->body($string); } }