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

From: Date: Sun, 31 Oct 2021 02:37:29 +0000
Subject: Bug #81575 [NEW]: Faulty mb_encode_mimeheader() example code
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19297@lists.php.net to get a copy of this message
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


Thread (3 messages)

« previous php.doc.bugs (#19297) next »