[PHP-BUG] Bug #81575 [NEW]: Faulty mb_encode_mimeheader() example code

[email protected] ("php at delegated dot net")
Newsgroups php.doc.bugs
Message-ID <[email protected]>
From:             php at delegated dot net
Operating system: n/a
PHP version:      Irrelevant
Package:          Documentation problem
Bug Type:         Bug
Bug description:Faulty mb_encode_mimeheader() example code

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 bug report at https://bugs.php.net/bug.php?id=81575&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81575&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81575&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81575&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81575&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81575&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81575&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81575&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81575&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81575&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81575&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81575&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81575&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81575&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81575&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81575&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81575&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81575&r=mysqlcfg
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.