php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58419 Wrong parsing - body/header overlap
Submitted: 2008-11-20 14:55 UTC Modified: 2021-03-02 12:53 UTC
From: anrdaemon at freemail dot ru Assigned:
Status: Verified Package: mailparse (PECL)
PHP Version: 5.2.6 OS: Windows
Private report: No CVE-ID: None
 [2008-11-20 14:55 UTC] anrdaemon at freemail dot ru
Description:
------------
PHP Version => 5.2.6

Extension Version => 2.1.5-dev
Revision => $Revision: 1.56 $

Message consist of *two* strings, CRLF delimited.
First string looks like header, but second string immediately following it without required delimiter.


To: "Daemon" <Daemon@daemon2.darkdragon>
It has been made known to me that inside each of us, the Light resides...


Reproduce code:
---------------
<?php

$buffer = "To: my@localhost\r\nHello myself!\r\n";
$msg = mailparse_msg_create();

if(mailparse_msg_parse($msg, $buffer))
{

  $rc = mailparse_msg_get_structure($msg);
  $_rc = var_export($rc, true);
  echo "---------- message structure ----------\n{$_rc}\n";

  foreach($rc as $section)
  {
    $part = mailparse_msg_get_part($msg, $section);
    $data = mailparse_msg_get_part_data($part);
    $_d = var_export($data, true);
    echo "---------- section {$section} details ----------\n{$_d}\n";

    $body = mailparse_msg_extract_part($part, $buffer, NULL);
    echo "---------- section {$section} body ----------\n{$body}\n---------- section {$section} end ----------\n";
  }
}

?>

Expected result:
----------------
Error in parsing or at least no header in structure.

Actual result:
--------------
---------- message structure ----------
array (
  0 => '1',
)
---------- section 1 details ----------
array (
  'headers' =>
  array (
    'to' => 'my@localhost',
  ),
  'starting-pos' => 0,
  'starting-pos-body' => 0,
  'ending-pos' => 33,
  'ending-pos-body' => 31,
  'line-count' => 2,
  'body-line-count' => 0,
  'charset' => 'us-ascii',
  'transfer-encoding' => '8bit',
  'content-type' => 'text/plain; (error)',
  'content-base' => '/',
)
---------- section 1 body ----------
To: my@localhost
Hello myself!

---------- section 1 end ----------

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-20 14:58 UTC] anrdaemon at freemail dot ru
PHP Version => 5.2.6

Extension Version => 2.1.5-dev
Revision => $Revision: 1.56 $

Message consist of *two* strings, CRLF delimited.
First string looks like header, but second string immediately following
it without required delimiter.
 [2021-03-02 12:53 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2021-03-02 12:53 UTC] cmb@php.net
I can confirm that this is still broken with mailparse 3.1.1 and
PHP 7.4.
 [2023-05-24 07:48 UTC] mybesthomedesigns at gmail dot com
My Best Home Designs are sharing latest news about home design, home decoration, home development, furniture, gardening, realestate etc. More info to visit: (https://mybesthomedesigns.com)github.com
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 00:01:30 2024 UTC