Spell out the folding arithmetic in addrAppend()
Name the separators that make up the line length instead of the bare 3, and refer to RFC 2822 like MAX_LINE_LENGTH does.
This commit is contained in:
1 parent
ce1b3ed5e6
commit
4ce8260f80
1 file changed
+6
-5
+6
-5
@@ -2647,17 +2647,18 @@ class PHPMailer
|
|||||||
$addresses[] = $this->addrFormat($address);
|
$addresses[] = $this->addrFormat($address);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fold between addresses so that no line exceeds the RFC 5322 limit,
|
//Fold between addresses so that no line exceeds the RFC 2822 line length limit
|
||||||
//leaving room for the comma at the end of a folded line
|
|
||||||
$header = $type . ': ' . array_shift($addresses);
|
$header = $type . ': ' . array_shift($addresses);
|
||||||
$lineLength = strlen($header);
|
$lineLength = strlen($header);
|
||||||
foreach ($addresses as $address) {
|
foreach ($addresses as $address) {
|
||||||
if ($lineLength + strlen($address) + 3 > static::MAX_LINE_LENGTH) {
|
//The address goes after ', ' and must still leave room for the ',' that ends
|
||||||
|
//the line if the next address gets folded
|
||||||
|
if ($lineLength + strlen(', ') + strlen($address) + strlen(',') > static::MAX_LINE_LENGTH) {
|
||||||
$header .= ',' . static::$LE . ' ' . $address;
|
$header .= ',' . static::$LE . ' ' . $address;
|
||||||
$lineLength = strlen($address) + 1;
|
$lineLength = strlen(' ') + strlen($address);
|
||||||
} else {
|
} else {
|
||||||
$header .= ', ' . $address;
|
$header .= ', ' . $address;
|
||||||
$lineLength += strlen($address) + 2;
|
$lineLength += strlen(', ') + strlen($address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user