php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49529 imap_mail_compose changes passed parameters
Submitted: 2009-09-11 11:24 UTC Modified: 2009-09-19 01:00 UTC
From: hrynek at hrynek dot com Assigned:
Status: No Feedback Package: IMAP related
PHP Version: 5.2.10 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-09-11 11:24 UTC] hrynek at hrynek dot com
Description:
------------
imap_mail_compose() corrupts passed $envelope parameter, even passed 
indirectly - check $headers and $this->headers used in sample code.

All address headers (from, to, cc, bcc, reply_to etc.) are changed and 
variable can't be passed to imap_mail_compose() next time, beacause 
function produces notice and wrong mail headers:
From: Asdf@NO HOST, UNEXPECTED_DATA_AFTER_ADDRESS@.SYNTAX-ERROR.

Any modification (uncomment line in sample) to variable 
prevents changes to $this->headers, but $headers is still being 
modified.

Reproduce code:
---------------
class test {
    protected $headers = array("from" => "Asdf Qwer <asdf@qwer.invalid>");
    protected $body = array(array(
        "type" => TYPETEXT,
        "subtype" => "plain",
        "contents.data" => "test message",
    ));
    protected function getHeaders() {
        return $this->headers;
    }
    public function compose() {
        $headers = $this->getHeaders();
        //$headers["from"] .= ""; // uncomment to fix
        var_dump($this->headers["from"]);
        imap_mail_compose($headers, $this->body);
        var_dump($this->headers["from"]);
    }
}
$test = new test();
$test->compose();

Expected result:
----------------
string(29) "Asdf Qwer <asdf@qwer.invalid>"
string(29) "Asdf Qwer <asdf@qwer.invalid>"

Actual result:
--------------
string(29) "Asdf Qwer <asdf@qwer.invalid>"
string(29) "Asdf Qwer<asdf@qwer.invalid>"

One space is replaced by 0x00.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-11 13:33 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

I can not reproduce this using your example script.
 [2009-09-19 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Jan 21 22:01:23 2021 UTC