|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-09-14 09:11 UTC] cmb@php.net
-Status: Open
+Status: Duplicate
-Assigned To:
+Assigned To: cmb
[2020-09-14 09:11 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 17:00:02 2025 UTC |
Description: ------------ When parsing emails with one line the starting position and ending position of the body are the same. if you add a second line with one character it jumps from 344 to 405, but then when you add a third line with a single character it shows end pos 407. So the issue seems to be with parsing the positions when there is just one line in body. Test script: --------------- <?php $message = <<< EOF MIME-Version: 1.0 Date: Tue, 12 Nov 2019 08:39:50 +0100 Message-ID: <CAD05h8p3WCJLqVLVLebaE03KskpD8+AGEHEjZJ1JvnJpuh2+1w@mail.gmail.com> Subject: Text Message From: Jamiel Sharief <somebody@gmail.com> To: Jamiel Sharief <somebody@gmail.com> Cc: somebody@gmail.com, Jamiel Sharief <somebody@gmail.com> Content-Type: text/plain; charset="UTF-8" One line email results in same starting and ending position. EOF; # Create resource $resource = mailparse_msg_create(); mailparse_msg_parse($resource, $message); $structure = mailparse_msg_get_structure($resource); $parts = []; foreach ($structure as $id) { $part = mailparse_msg_get_part($resource, $id); $parts[] = mailparse_msg_get_part_data($part); } # This is a bug with starting-pos-body print_r($parts);; Expected result: ---------------- [starting-pos] => 0 [starting-pos-body] => 344 [ending-pos] => 404 ending-pos-body] => 404 Actual result: -------------- [starting-pos] => 0 [starting-pos-body] => 344 [ending-pos] => 344 ending-pos-body] => 344