php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75825 mailparse_uudecode_all doesn't parse multiple files
Submitted: 2018-01-16 16:52 UTC Modified: 2021-09-03 10:15 UTC
From: cmanley at xs4all dot nl Assigned: cmb (profile)
Status: Closed Package: mailparse (PECL)
PHP Version: 7.0.27 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cmanley at xs4all dot nl
New email:
PHP Version: OS:

 

 [2018-01-16 16:52 UTC] cmanley at xs4all dot nl
Description:
------------
---
From manual page: http://www.php.net/function.mailparse-uudecode-all
---
If a uuencoded mail contains multiple files, then mailparse_uudecode_all() only parses the first found file and ignores the rest.

Test script:
---------------
<?php
# Save with UNIX line endings:
$data = <<<'EOD'
begin 644 .profile
M(R!^+RYP<F]F:6QE.B!E>&5C=71E9"!B>2!T:&4@8V]M;6%N9"!I;G1E<G!R
M971E<B!F;W(@;&]G:6X@<VAE;&QS+@HC(%1H:7,@9FEL92!I<R!N;W0@<F5A
M9"!B>2!B87-H*#$I+"!I9B!^+RYB87-H7W!R;V9I;&4@;W(@?B\N8F%S:%]L
M;V=I;@HC(&5X:7-T<RX*(R!S964@+W5S<B]S:&%R92]D;V,O8F%S:"]E>&%M
M<&QE<R]S=&%R='5P+69I;&5S(&9O<B!E>&%M<&QE<RX*(R!T:&4@9FEL97,@
M87)E(&QO8V%T960@:6X@=&AE(&)A<V@M9&]C('!A8VMA9V4N"@HC('1H92!D
M969A=6QT('5M87-K(&ES('-E="!I;B`O971C+W!R;V9I;&4[(&9O<B!S971T
M:6YG('1H92!U;6%S:PHC(&9O<B!S<V@@;&]G:6YS+"!I;G-T86QL(&%N9"!C
M;VYF:6=U<F4@=&AE(&QI8G!A;2UU;6%S:R!P86-K86=E+@HC=6UA<VL@,#(R
M"@HC(&EF(')U;FYI;F<@8F%S:`II9B!;("UN("(D0D%32%]615)324].(B!=
M.R!T:&5N"B`@("`C(&EN8VQU9&4@+F)A<VAR8R!I9B!I="!E>&ES=',*("`@
M(&EF(%L@+68@(B1(3TU%+RYB87-H<F,B(%T[('1H96X*"2X@(B1(3TU%+RYB
M87-H<F,B"B`@("!F:0IF:0H*(R!S970@4$%42"!S;R!I="!I;F-L=61E<R!U
M<V5R)W,@<')I=F%T92!B:6X@:68@:70@97AI<W1S"FEF(%L@+60@(B1(3TU%
M+V)I;B(@72`[('1H96X*("`@(%!!5$@](B1(3TU%+V)I;CHD4$%42"(*9FD*
`
end
begin 644 .bash_logout
M(R!^+RYB87-H7VQO9V]U=#H@97AE8W5T960@8GD@8F%S:"@Q*2!W:&5N(&QO
M9VEN('-H96QL(&5X:71S+@H*(R!W:&5N(&QE879I;F<@=&AE(&-O;G-O;&4@
M8VQE87(@=&AE('-C<F5E;B!T;R!I;F-R96%S92!P<FEV86-Y"@II9B!;("(D
M4TA,5DPB(#T@,2!=.R!T:&5N"B`@("!;("UX("]U<W(O8FEN+V-L96%R7V-O
H;G-O;&4@72`F)B`O=7-R+V)I;B]C;&5A<E]C;VYS;VQE("UQ"F9I"@``
`
end
begin 644 .selected_editor
`
end

EOD;
$h = fopen('data://text/plain,' . $data, 'r');
$h || die("Failed to open string!\n");
$parsed = mailparse_uudecode_all($h);
fclose($h);
print_r($parsed);


Expected result:
----------------
Array
(
    [0] => Array
        (
            [filename] => /tmp/mailparseVPoFAd
        )

    [1] => Array
        (
            [origfilename] => .profile
            [filename] => /tmp/mailparseQgOwZu
        )
    [2] => Array
        (
            [origfilename] => .bash_logout
            [filename] => /tmp/mailparseBLAAAA
        )
    [3] => Array
        (
            [origfilename] => .selected_editor
            [filename] => /tmp/mailparseFOOOOO
        )
)

Actual result:
--------------
Array
(
    [0] => Array
        (
            [filename] => /tmp/mailparseVPoFAd
        )

    [1] => Array
        (
            [origfilename] => .profile
            [filename] => /tmp/mailparseQgOwZu
        )

)

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-09-02 15:57 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2021-09-02 15:57 UTC] cmb@php.net
mailparse_uudecode_all() expects the uuencoded files to be
separated by empty lines.  Otherwise it parses multiple files,
ignoring the beginning and ending markers.  This looks like a bug
to me; not having the empty line appears to be common.
 [2021-09-03 10:15 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #75825: mailparse_uudecode_all doesn't parse multiple files
On GitHub:  https://github.com/php/pecl-mail-mailparse/pull/16
Patch:      https://github.com/php/pecl-mail-mailparse/pull/16.patch
 [2021-09-03 10:15 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2021-09-20 08:07 UTC] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/pecl-mail-mailparse/commit/bca9ef964c8bba46bd02ccbbad9828516bb524b0
Log: Fix #75825: mailparse_uudecode_all doesn't parse multiple files
 [2021-09-20 08:07 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 05:01:29 2024 UTC