Edit report at https://bugs.php.net/bug.php?id=81575&edit=1
ID: 81575
Updated by: [email protected]
Reported by: php at delegated dot net
Summary: Faulty mb_encode_mimeheader() example code
-Status: Verified
+Status: Closed
Type: Documentation Problem
Package: mbstring related
Operating System: n/a
PHP Version: Irrelevant
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmb69
Revision: https://github.com/php/doc-en/commit/936691e7449fe193b474f7d29df152952e9b8df6
Log: Fix #81575: Faulty mb_encode_mimeheader() example code
Previous Comments:
------------------------------------------------------------------------
[2021-11-02 16:49:18] [email protected]
Well, the example as is, is broken anyway, since an empty string
as display-name doesn't make much sense, and claiming that an
empty string (yes, I double-checked the source file with a hex
editor) would be Kanji makes no sense at all. Looking at the
Japanese translation, that 太郎 was likely lost while converting
the file to UTF-8 encoding or some other changes.
Anyhow, you are right that the result of mb_encode_mimeheader()
isn't an atom, and as such should be quoted.
------------------------------------------------------------------------
[2021-10-31 02:37:29] php at delegated dot net
Description:
------------
https://www.php.net/manual/en/function.mb-encode-mimeheader.php provides the example:
<?php
$name = ""; // kanji
$mbox = "kru";
$doma = "gtinn.mon";
$addr = mb_encode_mimeheader($name, "UTF-7", "Q") . " <" . $mbox . "@" . $doma . ">";
echo $addr;
?>
however, at least for some default Linux MTAs this is not safe. The name part must be quote escaped (if Q is being used, not an issue with B mode):
$addr = '"' . str_replace('"', '\"', mb_encode_mimeheader($name, "UTF-7", "Q")) . "\" <" . $mbox . "@" . $doma . ">";
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81575&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.