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: 2008-11-20 14:58 UTC
From: anrdaemon at freemail dot ru Assigned:
Status: Open Package: mailparse (PECL)
PHP Version: 5.2.6 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: anrdaemon at freemail dot ru
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC