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

ImapClient::tokenizeResponse() causes NOTICE error when using custom error handler #47

Open
scr34m opened this issue Jan 23, 2023 · 1 comment

Comments

@scr34m
Copy link

scr34m commented Jan 23, 2023

The error suppression doesn't work, if you have a custom error handler, at this line while (@list($name, $value) = $this->tokenizeResponse($line, 2)) { so it generates NOTICE when tokenizeResponse returns an empty array, https://github.com/javanile/php-imap2/blob/main/src/Roundcube/ImapClient.php#L2497.

The generated notice message is the following /vendor/javanile/php-imap2/src/Roundcube/ImapClient.php:2497 Undefined offset: 0 and /vendor/javanile/php-imap2/src/Roundcube/ImapClient.php:2496 Undefined offset: 1

To test simply use $line with UID 69)\n so it will be parsed as

array(2) {
  [0]=>
  string(3) "UID"
  [1]=>
  string(2) "69"
}

then remaining content is only )\n which is resulting an empty array php array(0) { }

A better solution would be to check return value instead of error suppression.

while (true) {
    $ret = $this->tokenizeResponse($line, 2);
    if (empty($ret) {
        break;
    }
   list($name, $value) = $ret;
@scr34m
Copy link
Author

scr34m commented Jan 23, 2023

Another suppressed error causing this message vendor/javanile/php-imap2/src/Roundcube/Charset.php:228 Undefined offset: 2 here https://github.com/javanile/php-imap2/blob/main/src/Roundcube/Charset.php#L228

else if (preg_match('/U[A-Z][A-Z](7|8|16|32)(BE|LE)*/', $str, $m)) {

If $str is simply UTF-8 then this generates a warning.

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