Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug in Mime::decode_mime_string #39

Open
gabriel-tandil opened this issue Dec 16, 2022 · 2 comments
Open

bug in Mime::decode_mime_string #39

gabriel-tandil opened this issue Dec 16, 2022 · 2 comments

Comments

@gabriel-tandil
Copy link

in Mime.php an attempt is made to access an array in a position that does not exist.

            foreach ($matches as $idx => $m) {
 ....
 ....
  
                $tmp[] = $text;
                if ($next_match = $matches[$idx+1]) {

message: Undefined offset: 1
file: /var/www/html/ver2/vendor/javanile/php-imap2/src/Roundcube/Mime.php
line: 210
trace:

#0 /var/www/html/ver2/vendor/javanile/php-imap2/src/Roundcube/Mime.php(210): yii\web\ErrorHandler->handleError('8', ''Undefined offs...', ''/var/www/html/...', '210', '['input' => '=?...') 
#1 /var/www/html/ver2/vendor/javanile/php-imap2/src/Roundcube/Mime.php(153): Javanile\Imap2\Roundcube\Mime::decode_mime_string(''=?iso-8859-1?Q...', 'NULL') 
#2 /var/www/html/ver2/vendor/javanile/php-imap2/src/Roundcube/MessageHeader.php(237): Javanile\Imap2\Roundcube\Mime::decode_header(''=?iso-8859-1?Q...', 'NULL') 
#3 /var/www/html/ver2/vendor/javanile/php-imap2/src/Message.php(341): Javanile\Imap2\Roundcube\MessageHeader->get(''to'', '???') 
#4 /var/www/html/ver2/vendor/javanile/php-imap2/bootstrap.php(1025): Javanile\Imap2\Message::fetchOverview('class Javanile\\...', '21315', '0') 
#5 /var/www/html/ver2/common/clasespropias/mails/ClienteMailImap2.php(297): ::imap2_fetch_overview('class Javanile\\...', '21315', '0') 
#6 /var/www/html/ver2/common/models/CuentasMail.php(678):
@gabriel-tandil
Copy link
Author

gabriel-tandil commented Dec 16, 2022

I changed line 210 to add an isset and the error does not occur, although I did not analyze if the solution is correct in all cases.
if (isset($matches[$idx+1]) && $next_match = $matches[$idx+1]) {

if you are ok with the solution, I will make a pull request.

@gabriel-tandil
Copy link
Author

The fix I mentioned has been in use for two weeks in the production environment and we haven't received any bug reports, so I created a pull request for it to be added to the repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant