note 67186 deleted from function.mb-encode-mimeheader by cmb
| From: | cmb@php.net | Date: | Thu, 17 Mar 2022 10:25:17 +0000 |
| Subject: | note 67186 deleted from function.mb-encode-mimeheader by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-217737@lists.php.net to get a copy of this message | ||
Note Submitter: chappy at citromail dot hu
----
I found a bad function.
<?php
function encodeHeader($input, $charset = 'ISO-8859-2')
{
preg_match_all('/(\\w*[\\x80-\\xFF]+\\w*)/', $input, $matches);
foreach ($matches[1] as $value) {
$replacement = preg_replace('/([\\x80-\\xFF])/e', '"=" .
strtoupper(dechex(ord("\\1")))', $value);
$input = str_replace($value, '=?' . $charset . '?Q?' . $replacement .
'?=', $input);
}
return $input;
}
?>
This function should be used:
<?php
function encodeHeader($input, $charset = 'ISO-8859-2')
{
$m=preg_match_all('/(\w*[\x80-\xFF]+\w*)/', $input, $matches);
if($m)$input=mb_encode_mimeheader($input,$charset, 'Q');
return $input;
}
?>