From 91b03e52f11375c3be5701a4ba6fb2d07d5b72c0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 14 Mar 2019 21:18:17 -0700 Subject: email_header_encode() producing lines of illegal length because header field length was not considered in length calculation. --- include/network.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include/network.php') diff --git a/include/network.php b/include/network.php index 12f2ad4e9..3e8134a32 100644 --- a/include/network.php +++ b/include/network.php @@ -874,13 +874,16 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority = } -function email_header_encode($in_str, $charset = 'UTF-8') { +function email_header_encode($in_str, $charset = 'UTF-8', $header = 'Subject') { + + $out_str = $in_str; $need_to_convert = false; for($x = 0; $x < strlen($in_str); $x ++) { if((ord($in_str[$x]) == 0) || ((ord($in_str[$x]) > 128))) { $need_to_convert = true; + break; } } @@ -896,7 +899,7 @@ function email_header_encode($in_str, $charset = 'UTF-8') { // determine length of encoded text within chunks // and ensure length is even - $length = 75 - strlen($start) - strlen($end); + $length = 75 - strlen($start) - strlen($end) - (strlen($header) + 2); /* [EDIT BY danbrown AT php DOT net: The following -- cgit v1.2.3