note 115840 added to function.quoted-printable-encode
| From: | jurgen at edesign dot nl | Date: | Thu, 02 Oct 2014 09:16:16 +0000 |
| Subject: | note 115840 added to function.quoted-printable-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200564@lists.php.net to get a copy of this message | ||
Both PHP's native implementation and the function of ericth at NOSPAM dot pennyworth dot com
(below) contain an feature/error (usage for SMTP mismatch) which has been solved in my adjustment
below.
The error causes a text containing period character(s), when passed through these functions, end up
with encoded lines starting with a period character, the first period character on that line will be
discarded when it is transported over SMTP.
Solution: add (another) leading '.' to period characters which would end up as first
character on a line when encoded.
See http://stackoverflow.com/a/13949483:
"This is a dirty artifact of your transport layer... SMTP is the most probable culprit (see the
call for caution in the mail function documentation) but there may be other low level mecanisms that
behave similarly. For example if you tweaked the sendmail_path setting or use a buggy sendmail
program you may experience similar woes."
<?php
define('PHP_QPRINT_MAXL', 75);
function leading_dot_fixed_php_quot_print_encode($str)
{
$lp = 0;
$ret = '';
$hex = "0123456789ABCDEF";
$length = strlen($str);
$str_index = 0;
while ($length--) {
if ((($c = $str[$str_index++]) == "\015") && ($str[$str_index] ==
"\012") && $length > 0) {
$ret .= "\015";
$ret .= $str[$str_index++];
$length--;
$lp = 0;
} else {
if (ctype_cntrl($c)
|| (ord($c) == 0x7f)
|| (ord($c) & 0x80)
|| ($c == '=')
|| (($c == ' ') && ($str[$str_index] == "\015")))
{
if (($lp += 3) > PHP_QPRINT_MAXL)
{
$ret .= '=';
$ret .= "\015";
$ret .= "\012";
$lp = 3;
}
$ret .= '=';
$ret .= $hex[ord($c) >> 4];
$ret .= $hex[ord($c) & 0xf];
}
else
{
if ((++$lp) > PHP_QPRINT_MAXL)
{
$ret .= '=';
$ret .= "\015";
$ret .= "\012";
$lp = 1;
}
$ret .= $c;
if($lp == 1 && $c == '.') {
$ret .= '.';
$lp++;
}
}
}
}
return $ret;
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 212.67.186.52
----
Manual Page -- http://php.net/manual/en/function.quoted-printable-encode.php
Edit -- https://master.php.net/note/edit/115840
Del: integrated -- https://master.php.net/note/delete/115840/integrated
Del: useless -- https://master.php.net/note/delete/115840/useless
Del: bad code -- https://master.php.net/note/delete/115840/bad+code
Del: spam -- https://master.php.net/note/delete/115840/spam
Del: non-english -- https://master.php.net/note/delete/115840/non-english
Del: in docs -- https://master.php.net/note/delete/115840/in+docs
Del: other reasons-- https://master.php.net/note/delete/115840
Reject -- https://master.php.net/note/reject/115840
Search -- https://master.php.net/manage/user-notes.php