From ff2d721680f9f9ede820e69e3116fe3684d6149e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Thu, 25 Jan 2024 19:17:29 +0100 Subject: [PATCH] Fix more CS whitespace (#9318) * fix "no_useless_else" manually * fix some "blank_line_before_statement" * two manual changes * Revert "fix some "blank_line_before_statement"" This reverts commit 2cc857c00e21e157922f885709479081127f07ce. * fix some "blank_line_before_statement" using patched fixer (after "}" only) * fix continue/break too --- .php-cs-fixer.dist.php | 1 - bin/deluser.sh | 2 + bin/msgimport.sh | 1 + plugins/debug_logger/runlog/runlog.php | 3 +- plugins/enigma/lib/enigma_engine.php | 2 + .../lib/Roundcube/rcube_sieve_engine.php | 8 ++- .../lib/Roundcube/rcube_sieve_script.php | 12 +++-- .../lib/Roundcube/rcube_sieve_vacation.php | 4 +- plugins/password/drivers/domainfactory.php | 1 + plugins/password/drivers/pwned.php | 4 +- plugins/password/drivers/xmail.php | 2 + plugins/password/password.php | 1 + program/actions/contacts/delete.php | 1 + program/actions/contacts/index.php | 1 + program/actions/mail/compose.php | 6 ++- program/actions/mail/show.php | 1 + program/include/rcmail_oauth.php | 4 ++ program/include/rcmail_output_html.php | 12 ++++- program/include/rcmail_sendmail.php | 4 +- program/include/rcmail_utils.php | 3 ++ program/lib/Roundcube/bootstrap.php | 1 + program/lib/Roundcube/html.php | 5 +- program/lib/Roundcube/rcube.php | 1 + program/lib/Roundcube/rcube_addressbook.php | 2 + program/lib/Roundcube/rcube_cache.php | 1 + program/lib/Roundcube/rcube_charset.php | 1 + program/lib/Roundcube/rcube_config.php | 10 ++-- program/lib/Roundcube/rcube_db.php | 9 ++-- program/lib/Roundcube/rcube_html2text.php | 2 +- program/lib/Roundcube/rcube_imap.php | 46 ++++++++-------- program/lib/Roundcube/rcube_imap_cache.php | 2 + program/lib/Roundcube/rcube_imap_generic.php | 9 ++++ program/lib/Roundcube/rcube_imap_search.php | 4 +- program/lib/Roundcube/rcube_ldap.php | 3 ++ program/lib/Roundcube/rcube_ldap_generic.php | 1 + program/lib/Roundcube/rcube_message.php | 1 + program/lib/Roundcube/rcube_mime.php | 1 + program/lib/Roundcube/rcube_plugin.php | 4 +- program/lib/Roundcube/rcube_plugin_api.php | 4 +- program/lib/Roundcube/rcube_result_thread.php | 1 + program/lib/Roundcube/rcube_session.php | 8 ++- program/lib/Roundcube/rcube_tnef_decoder.php | 4 ++ program/lib/Roundcube/rcube_utils.php | 54 +++++++++---------- program/lib/Roundcube/rcube_vcard.php | 3 ++ program/lib/Roundcube/rcube_washtml.php | 1 + 45 files changed, 162 insertions(+), 89 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index a0f99dadb..b5751524e 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -101,7 +101,6 @@ return (new Config()) 'modernize_types_casting' => false, 'no_blank_lines_after_phpdoc' => false, 'no_break_comment' => false, - 'no_useless_else' => false, 'phpdoc_annotation_without_dot' => false, 'phpdoc_summary' => false, 'string_length_to_empty' => false, diff --git a/bin/deluser.sh b/bin/deluser.sh index dc0a786e7..28418e42d 100755 --- a/bin/deluser.sh +++ b/bin/deluser.sh @@ -37,6 +37,7 @@ function _die($msg, $usage = false) if ($usage) { print_usage(); } + exit(1); } @@ -61,6 +62,7 @@ if (!empty($args['age']) && ($age = intval($args['age']))) { } system(sprintf('%s/deluser.sh --host=%s %s', INSTALL_PATH . 'bin', escapeshellarg($user['mail_host']), escapeshellarg($user['username']))); } + exit(0); } diff --git a/bin/msgimport.sh b/bin/msgimport.sh index 6d6924556..fdf0adfc2 100755 --- a/bin/msgimport.sh +++ b/bin/msgimport.sh @@ -90,6 +90,7 @@ if ($IMAP->connect($host, $args['user'], $args['pass'], $imap_port, $imap_ssl)) } $message = ''; } + continue; } diff --git a/plugins/debug_logger/runlog/runlog.php b/plugins/debug_logger/runlog/runlog.php index 09626633c..1a96ae384 100644 --- a/plugins/debug_logger/runlog/runlog.php +++ b/plugins/debug_logger/runlog/runlog.php @@ -159,7 +159,7 @@ class runlog $buffer .= "{$tag}: "; } $msg = str_replace("\n", '', $msg); - $buffer .= "{$msg}"; + $buffer .= $msg; if (!empty($this->timestamp)) { $buffer = sprintf('[%s] %s', date($this->timestamp, time()), $buffer); } @@ -197,6 +197,7 @@ class runlog for ($i = 0; $i < $this->indent; $i++) { $buf .= ' '; } + return $buf; } diff --git a/plugins/enigma/lib/enigma_engine.php b/plugins/enigma/lib/enigma_engine.php index 4867ab01f..731504a54 100644 --- a/plugins/enigma/lib/enigma_engine.php +++ b/plugins/enigma/lib/enigma_engine.php @@ -479,6 +479,7 @@ class enigma_engine if ($mode === 'signed') { $body .= $line; } + break 2; // ignore anything after this line case 'encrypted-start': $body = $line; @@ -488,6 +489,7 @@ class enigma_engine if ($mode === 'encrypted') { $body .= $line; } + break 2; // ignore anything after this line } diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php index ffe631dae..44b467b0e 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php @@ -991,6 +991,7 @@ class rcube_sieve_engine $type = 'fileinto'; $this->form['actions'][$i]['copy'] = true; } + break; case 'reject': case 'ereject': @@ -1000,6 +1001,7 @@ class rcube_sieve_engine // if ($target == '') { // $this->errors['actions'][$i]['targetarea'] = $this->plugin->gettext('cannotbeempty'); // } + break; case 'redirect': case 'redirect_copy': @@ -1111,6 +1113,7 @@ class rcube_sieve_engine if ($this->form['actions'][$i][$interval_type] && !preg_match('/^[0-9]+$/', $this->form['actions'][$i][$interval_type])) { $this->errors['actions'][$i]['interval'] = $this->plugin->gettext('forbiddenchars'); } + break; case 'set': $this->form['actions'][$i]['name'] = $varnames[$idx]; @@ -1128,6 +1131,7 @@ class rcube_sieve_engine if (!isset($varvalues[$idx]) || $varvalues[$idx] === '') { $this->errors['actions'][$i]['value'] = $this->plugin->gettext('cannotbeempty'); } + break; case 'notify': if (empty($notifymethods[$idx])) { @@ -3397,9 +3401,9 @@ class rcube_sieve_engine if (empty($addr['mailto']) || !rcube_utils::check_email($addr['mailto'])) { $this->errors['actions'][$i][$field] = $this->plugin->gettext('noemailwarning'); break; - } else { - $from[$idx] = format_email_recipient($addr['mailto'], $addr['name']); } + + $from[$idx] = format_email_recipient($addr['mailto'], $addr['name']); } // Only one address is allowed (at least on cyrus imap) diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php index 00c582990..58328480d 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php @@ -454,6 +454,7 @@ class rcube_sieve_script if ((is_string($action['value']) && strlen($action['value']) > 0) || (is_array($action['value']) && !empty($action['value']))) { $action_script .= ' ' . self::escape_string($action['value']); } + break; case 'keep': case 'discard': @@ -1202,10 +1203,9 @@ class rcube_sieve_script if (preg_match('/[\r\n\0]/', $str)) { return sprintf("text:\r\n%s\r\n.\r\n", self::escape_multiline_string($str)); } + // quoted-string - else { - return '"' . addcslashes($str, '\\"') . '"'; - } + return '"' . addcslashes($str, '\\"') . '"'; } /** @@ -1295,6 +1295,7 @@ class rcube_sieve_script $result[] = $sep; break 2; } + break; // bracket-comment (<< reindent once https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7179 is fixed) case '/': @@ -1306,16 +1307,17 @@ class rcube_sieve_script $position = $length; } } + break; // hash-comment (<< reindent once https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7179 is fixed) case '#': if ($lf_pos = strpos($str, "\n", $position)) { $position = $lf_pos + 1; break; - } else { - $position = $length; } + $position = $length; + // String atom (<< reindent once https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7179 is fixed) default: // empty or one character diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php index 4a0880c6f..802941f19 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php @@ -223,9 +223,9 @@ class rcube_sieve_vacation extends rcube_sieve_engine if (empty($addr['mailto']) || !rcube_utils::check_email($addr['mailto'])) { $error = $from_error = 'noemailwarning'; break; - } else { - $from[$idx] = format_email_recipient($addr['mailto'], $addr['name']); } + + $from[$idx] = format_email_recipient($addr['mailto'], $addr['name']); } // Only one address is allowed (at least on cyrus imap) diff --git a/plugins/password/drivers/domainfactory.php b/plugins/password/drivers/domainfactory.php index 41cc0a04b..66298e123 100644 --- a/plugins/password/drivers/domainfactory.php +++ b/plugins/password/drivers/domainfactory.php @@ -75,6 +75,7 @@ class rcube_domainfactory_password foreach ($errors[1] as $error) { $error_message .= trim(rcube_charset::convert($error, 'ISO-8859-15')) . ' '; } + return ['code' => PASSWORD_ERROR, 'message' => $error_message]; } } diff --git a/plugins/password/drivers/pwned.php b/plugins/password/drivers/pwned.php index 8d409637e..b5da72852 100644 --- a/plugins/password/drivers/pwned.php +++ b/plugins/password/drivers/pwned.php @@ -164,9 +164,9 @@ class rcube_pwned_password { if ($this->can_curl()) { return $this->retrieve_curl($url); - } else { - return $this->retrieve_fopen($url); } + + return $this->retrieve_fopen($url); } public function retrieve_curl($url) diff --git a/plugins/password/drivers/xmail.php b/plugins/password/drivers/xmail.php index 1ddf240bc..caa99266f 100644 --- a/plugins/password/drivers/xmail.php +++ b/plugins/password/drivers/xmail.php @@ -89,6 +89,7 @@ class XMail if (substr(socket_read($this->socket, 512, \PHP_BINARY_READ), 0, 1) != '+') { return false; } + return true; } @@ -114,6 +115,7 @@ class XMail socket_close($this->socket); return false; } + return true; } diff --git a/plugins/password/password.php b/plugins/password/password.php index 6edb721a3..93eadb6ce 100644 --- a/plugins/password/password.php +++ b/plugins/password/password.php @@ -666,6 +666,7 @@ class password extends rcube_plugin 'message' => 'Password plugin: Your PHP installation does not have hash() function', ], true, true); } + break; case 'ad': $crypted = rcube_charset::convert('"' . $password . '"', RCUBE_CHARSET, 'UTF-16LE'); diff --git a/program/actions/contacts/delete.php b/program/actions/contacts/delete.php index 69e71d343..1367feebe 100644 --- a/program/actions/contacts/delete.php +++ b/program/actions/contacts/delete.php @@ -48,6 +48,7 @@ class rcmail_action_contacts_delete extends rcmail_action_contacts_index $rcmail->output->command('list_contacts'); $rcmail->output->send(); } + continue; } diff --git a/program/actions/contacts/index.php b/program/actions/contacts/index.php index 676953330..05e5ce96c 100644 --- a/program/actions/contacts/index.php +++ b/program/actions/contacts/index.php @@ -679,6 +679,7 @@ class rcmail_action_contacts_index extends rcmail_action } else { $val = null; } + break; default: $val = rcube::Q($row[$col]); diff --git a/program/actions/mail/compose.php b/program/actions/mail/compose.php index d10830ace..a1bfe3cd2 100644 --- a/program/actions/mail/compose.php +++ b/program/actions/mail/compose.php @@ -604,6 +604,7 @@ class rcmail_action_mail_compose extends rcmail_action_mail_index '_part' => $pgp_mime_part->mime_id, ]); } + continue; } @@ -1029,6 +1030,7 @@ class rcmail_action_mail_compose extends rcmail_action_mail_index if (substr_count($body, "\n", $sp) < $sig_max_lines) { $body = substr($body, 0, max(0, $sp - 1)); } + break; } } @@ -1310,9 +1312,9 @@ class rcmail_action_mail_compose extends rcmail_action_mail_index // basename() is not unicode safe and locale dependent if (stristr(\PHP_OS, 'win') || stristr(\PHP_OS, 'netware')) { return preg_replace('/^.*[\\\\\\/]/', '', $filename); - } else { - return preg_replace('/^.*[\/]/', '', $filename); } + + return preg_replace('/^.*[\/]/', '', $filename); } /** diff --git a/program/actions/mail/show.php b/program/actions/mail/show.php index dc82d8c5f..ee501737c 100644 --- a/program/actions/mail/show.php +++ b/program/actions/mail/show.php @@ -671,6 +671,7 @@ class rcmail_action_mail_show extends rcmail_action_mail_index $out .= html::span('part-notice', $rcmail->gettext('encryptedmessage')); } } + continue; } elseif (!$part->size) { continue; diff --git a/program/include/rcmail_oauth.php b/program/include/rcmail_oauth.php index 78e877d88..28568548b 100644 --- a/program/include/rcmail_oauth.php +++ b/program/include/rcmail_oauth.php @@ -679,6 +679,7 @@ class rcmail_oauth // store crypted code_verifier because session is going to be killed $this->login_phase['code_verifier'] = $_SESSION['oauth_code_verifier']; } + return true; } catch (RequestException $e) { $this->last_error = 'OAuth token request failed: ' . $e->getMessage(); @@ -700,6 +701,7 @@ class rcmail_oauth 'line' => __LINE__, ], true, false); } + return false; } @@ -1161,6 +1163,7 @@ class rcmail_oauth ], true, false); continue 2; // continue on next foreach iteration } + break; case 'language': // normalize language @@ -1174,6 +1177,7 @@ class rcmail_oauth ], true, false); continue 2; // continue on next foreach iteration } + break; } $data[$rc_key] = $value; diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php index 5d0f4ad22..042d3359e 100644 --- a/program/include/rcmail_output_html.php +++ b/program/include/rcmail_output_html.php @@ -779,9 +779,9 @@ class rcmail_output_html extends rcmail_output $this->base_path = preg_replace('!plugins/\w+/!', '', $skin_path); $skin_dir = preg_replace('!^plugins/!', '', $skin_path); break; - } else { - $path = false; } + + $path = false; } // read template file @@ -1123,8 +1123,10 @@ class rcmail_output_html extends rcmail_output if ($content_end === null) { $content_end = $tag_start; } + break 2; } + break; case 'elseif': if (!$level) { @@ -1142,6 +1144,7 @@ class rcmail_output_html extends rcmail_output } } } + break; case 'else': if (!$level) { @@ -1153,6 +1156,7 @@ class rcmail_output_html extends rcmail_output $content_start = $tag_end; } } + break; } @@ -1268,6 +1272,7 @@ class rcmail_output_html extends rcmail_output if (is_array($value) && !empty($value[$_SESSION['storage_host']])) { $value = $value[$_SESSION['storage_host']]; } + break; case 'request': $value = rcube_utils::get_input_value($name, rcube_utils::INPUT_GPC); @@ -1337,6 +1342,7 @@ class rcmail_output_html extends rcmail_output if (!empty($attrib['name']) || !empty($attrib['command'])) { return $this->button($attrib); } + break; // frame (<< reindent once https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7179 is fixed) case 'frame': @@ -1381,6 +1387,7 @@ class rcmail_output_html extends rcmail_output return $label; } + break; case 'add_label': $this->add_label($attrib['name']); @@ -1431,6 +1438,7 @@ class rcmail_output_html extends rcmail_output $hook = $this->app->plugins->exec_hook('template_container', $attrib + ['content' => '']); return $hook['content']; } + break; // return code for a specific application object (<< reindent once https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7179 is fixed) case 'object': diff --git a/program/include/rcmail_sendmail.php b/program/include/rcmail_sendmail.php index 1401b868c..ac1ad4cfc 100644 --- a/program/include/rcmail_sendmail.php +++ b/program/include/rcmail_sendmail.php @@ -1480,9 +1480,9 @@ class rcmail_sendmail if ($create) { if (!$rcmail->storage->folder_exists($folder)) { return $rcmail->storage->create_folder($folder, true); - } else { - return $rcmail->storage->subscribe($folder); } + + return $rcmail->storage->subscribe($folder); } return false; diff --git a/program/include/rcmail_utils.php b/program/include/rcmail_utils.php index c6ac75e66..d9a44701c 100644 --- a/program/include/rcmail_utils.php +++ b/program/include/rcmail_utils.php @@ -101,6 +101,7 @@ class rcmail_utils if (!empty($opts['errors'])) { rcube::raise_error("Specified database schema directory doesn't exist.", false, true); } + return false; } @@ -168,6 +169,7 @@ class rcmail_utils if (!empty($opts['errors'])) { rcube::raise_error('DDL Upgrade files for ' . $db->db_provider . ' driver not found.', false, true); } + return false; } @@ -198,6 +200,7 @@ class rcmail_utils if (!empty($opts['errors'])) { rcube::raise_error("Error in DDL upgrade {$v}: {$error}", false, true); } + return false; } elseif (empty($opts['quiet'])) { echo "[OK]\n"; diff --git a/program/lib/Roundcube/bootstrap.php b/program/lib/Roundcube/bootstrap.php index ed7b7452c..f160893e6 100644 --- a/program/lib/Roundcube/bootstrap.php +++ b/program/lib/Roundcube/bootstrap.php @@ -58,6 +58,7 @@ foreach ($config as $optname => $optval) { } else { echo $error; } + exit(1); } } diff --git a/program/lib/Roundcube/html.php b/program/lib/Roundcube/html.php index f04a11ce0..875ca204f 100644 --- a/program/lib/Roundcube/html.php +++ b/program/lib/Roundcube/html.php @@ -80,10 +80,11 @@ class html if (isset($content) || in_array($tagname, self::$containers)) { $suffix = !empty($attrib['noclose']) ? $suffix : '' . $suffix; unset($attrib['noclose'], $attrib['nl']); + return '<' . $tagname . self::attrib_string($attrib, $allowed) . '>' . $content . $suffix; - } else { - return '<' . $tagname . self::attrib_string($attrib, $allowed) . '>' . $suffix; } + + return '<' . $tagname . self::attrib_string($attrib, $allowed) . '>' . $suffix; } /** diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php index 53bf75b45..d52940570 100644 --- a/program/lib/Roundcube/rcube.php +++ b/program/lib/Roundcube/rcube.php @@ -1447,6 +1447,7 @@ class rcube if (defined('ROUNDCUBE_TEST_MODE') && ROUNDCUBE_TEST_MODE) { throw new Exception('Error raised'); } + exit(1); } } diff --git a/program/lib/Roundcube/rcube_addressbook.php b/program/lib/Roundcube/rcube_addressbook.php index 587852e6c..4547d88e7 100644 --- a/program/lib/Roundcube/rcube_addressbook.php +++ b/program/lib/Roundcube/rcube_addressbook.php @@ -688,6 +688,7 @@ abstract class rcube_addressbook $result[] = $contact[$field]; } } + return $result; }; @@ -714,6 +715,7 @@ abstract class rcube_addressbook $keys = ['prefix', 'firstname', 'middlename', 'surname', 'suffix']; $fn = implode(' ', $get_names($contact, $keys)); } + break; default: $plugin = rcube::get_instance()->plugins->exec_hook('contact_listname', ['contact' => $contact]); diff --git a/program/lib/Roundcube/rcube_cache.php b/program/lib/Roundcube/rcube_cache.php index bd3f79103..a7368d69c 100644 --- a/program/lib/Roundcube/rcube_cache.php +++ b/program/lib/Roundcube/rcube_cache.php @@ -202,6 +202,7 @@ class rcube_cache if (is_array($v)) { sort($v); } + return is_string($v) ? $v : serialize($v); }; diff --git a/program/lib/Roundcube/rcube_charset.php b/program/lib/Roundcube/rcube_charset.php index 86ead8230..4e2b79d7a 100644 --- a/program/lib/Roundcube/rcube_charset.php +++ b/program/lib/Roundcube/rcube_charset.php @@ -629,6 +629,7 @@ class rcube_charset $input[$k] = $v; } } + return $input; } diff --git a/program/lib/Roundcube/rcube_config.php b/program/lib/Roundcube/rcube_config.php index 7e1c389f4..65bcf7009 100644 --- a/program/lib/Roundcube/rcube_config.php +++ b/program/lib/Roundcube/rcube_config.php @@ -576,12 +576,12 @@ class rcube_config $delim = $this->prop['mail_header_delimiter']; if ($delim == "\n" || $delim == "\r\n") { return $delim; - } else { - rcube::raise_error([ - 'code' => 500, 'file' => __FILE__, 'line' => __LINE__, - 'message' => 'Invalid mail_header_delimiter setting', - ], true, false); } + + rcube::raise_error([ + 'code' => 500, 'file' => __FILE__, 'line' => __LINE__, + 'message' => 'Invalid mail_header_delimiter setting', + ], true, false); } $php_os = strtolower(substr(\PHP_OS, 0, 3)); diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php index 919fc58a4..3391d10f5 100644 --- a/program/lib/Roundcube/rcube_db.php +++ b/program/lib/Roundcube/rcube_db.php @@ -638,11 +638,12 @@ class rcube_db if (preg_match('/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/ims', $result->queryString, $m)) { $query = $this->dbh->query('SELECT COUNT(*) FROM ' . $m[1], PDO::FETCH_NUM); return $query ? intval($query->fetchColumn(0)) : false; - } else { - $num = count($result->fetchAll()); - $result->execute(); // re-execute query because there's no seek(0) - return $num; } + + $num = count($result->fetchAll()); + $result->execute(); // re-execute query because there's no seek(0) + + return $num; } return false; diff --git a/program/lib/Roundcube/rcube_html2text.php b/program/lib/Roundcube/rcube_html2text.php index 0435f3810..63fab2fc2 100644 --- a/program/lib/Roundcube/rcube_html2text.php +++ b/program/lib/Roundcube/rcube_html2text.php @@ -584,7 +584,7 @@ class rcube_html2text if (substr($link, 0, 1) != '/') { $url .= '/'; } - $url .= "{$link}"; + $url .= $link; } if ($this->_links_mode === self::LINKS_NONE) { diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php index 8b60aeef9..cb66c28df 100644 --- a/program/lib/Roundcube/rcube_imap.php +++ b/program/lib/Roundcube/rcube_imap.php @@ -1218,28 +1218,28 @@ class rcube_imap extends rcube_storage $a_msg_headers = $this->fetch_headers($folder, $a_index); return array_values($a_msg_headers); - } else { - // for small result set we can fetch all messages headers - $a_index = $index->get(); - $a_msg_headers = $this->fetch_headers($folder, $a_index, false); - - // return empty array if no messages found - if (!is_array($a_msg_headers) || empty($a_msg_headers)) { - return []; - } - - // if not already sorted - $a_msg_headers = rcube_imap_generic::sortHeaders( - $a_msg_headers, $this->sort_field, $this->sort_order); - - $a_msg_headers = array_slice(array_values($a_msg_headers), $from, $this->page_size); - - if ($slice) { - $a_msg_headers = array_slice($a_msg_headers, -$slice, $slice); - } - - return $a_msg_headers; } + + // for small result set we can fetch all messages headers + $a_index = $index->get(); + $a_msg_headers = $this->fetch_headers($folder, $a_index, false); + + // return empty array if no messages found + if (!is_array($a_msg_headers) || empty($a_msg_headers)) { + return []; + } + + // if not already sorted + $a_msg_headers = rcube_imap_generic::sortHeaders( + $a_msg_headers, $this->sort_field, $this->sort_order); + + $a_msg_headers = array_slice(array_values($a_msg_headers), $from, $this->page_size); + + if ($slice) { + $a_msg_headers = array_slice($a_msg_headers, -$slice, $slice); + } + + return $a_msg_headers; } /** @@ -1713,9 +1713,9 @@ class rcube_imap extends rcube_storage if (!$this->check_connection()) { if ($this->threading) { return new rcube_result_thread(); - } else { - return new rcube_result_index(); } + + return new rcube_result_index(); } if ($this->options['skip_deleted'] && !preg_match('/UNDELETED/', $criteria)) { diff --git a/program/lib/Roundcube/rcube_imap_cache.php b/program/lib/Roundcube/rcube_imap_cache.php index c4c6d32d2..3d32d1752 100644 --- a/program/lib/Roundcube/rcube_imap_cache.php +++ b/program/lib/Roundcube/rcube_imap_cache.php @@ -183,6 +183,7 @@ class rcube_imap_cache if ($result->get_parameters('ORDER') != $sort_order) { $result->revert(); } + return $result; } } @@ -896,6 +897,7 @@ class rcube_imap_cache if (!$this->skip_deleted && $mbox_data['EXISTS'] != $object->count_messages()) { return false; } + return true; } diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php index c8b0fde91..e7c38e5cd 100644 --- a/program/lib/Roundcube/rcube_imap_generic.php +++ b/program/lib/Roundcube/rcube_imap_generic.php @@ -465,6 +465,7 @@ class rcube_imap_generic if (strtoupper($m[1]) == 'BYE') { $this->closeSocket(); } + return true; } @@ -576,6 +577,7 @@ class rcube_imap_generic for ($i = 0; $i < $size; $i++) { $result .= chr(ord($str1[$i]) ^ ord($str2[$i])); } + return $result; }; @@ -1218,11 +1220,13 @@ class rcube_imap_generic if ($len = strspn($line, '0123456789', $pos)) { $this->data[$token] = (int) substr($line, $pos, $len); } + break; case 'HIGHESTMODSEQ': if ($len = strspn($line, '0123456789', $pos)) { $this->data[$token] = (string) substr($line, $pos, $len); } + break; case 'NOMODSEQ': $this->data[$token] = true; @@ -1234,6 +1238,7 @@ class rcube_imap_generic $flags = substr($line, $start + 1, $end - $start - 1); $this->data[$token] = explode(' ', $flags); } + break; } } elseif (preg_match('/^\* ([0-9]+) (EXISTS|RECENT|FETCH)/i', $line, $match)) { @@ -2578,6 +2583,7 @@ class rcube_imap_generic if (preg_match('/charset\s*=\s*"?([a-z0-9\-\.\_]+)"?/i', $string, $regs)) { $result[$id]->charset = $regs[1]; } + break; case 'in-reply-to': $result[$id]->in_reply_to = str_replace(["\n", '<', '>'], '', $string); @@ -2593,6 +2599,7 @@ class rcube_imap_generic if (preg_match('/^(\d+)/', $string, $matches)) { $result[$id]->priority = intval($matches[1]); } + break; default: if (strlen($field) < 3) { @@ -3377,6 +3384,7 @@ class rcube_imap_generic unset($ret[$i - 1]); unset($ret[$i]); } + return $ret; } @@ -3675,6 +3683,7 @@ class rcube_imap_generic unset($mbox); unset($data[$i]); } + continue; } elseif (isset($mbox)) { $attribs = $data[++$i]; diff --git a/program/lib/Roundcube/rcube_imap_search.php b/program/lib/Roundcube/rcube_imap_search.php index 8643370fb..4cffb0206 100644 --- a/program/lib/Roundcube/rcube_imap_search.php +++ b/program/lib/Roundcube/rcube_imap_search.php @@ -197,9 +197,9 @@ class rcube_imap_search_job // extends Stackable if ($this->threading) { return new rcube_result_thread($this->folder); - } else { - return new rcube_result_index($this->folder); } + + return new rcube_result_index($this->folder); } if ($this->worker->options['skip_deleted'] && !preg_match('/UNDELETED/', $criteria)) { diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php index 879648aee..f91b7c125 100644 --- a/program/lib/Roundcube/rcube_ldap.php +++ b/program/lib/Roundcube/rcube_ldap.php @@ -816,6 +816,7 @@ class rcube_ldap extends rcube_addressbook $result->count++; } } + return $result; } @@ -1337,6 +1338,7 @@ class rcube_ldap extends rcube_addressbook } elseif ($old !== null) { $subdata[$fld] = $old; } + continue; } @@ -1737,6 +1739,7 @@ class rcube_ldap extends rcube_addressbook if ($dt = rcube_utils::anytodatetime($ldap_data[$fld])) { $ldap_data[$fld] = $dt->format($format['format']); } + break; } } diff --git a/program/lib/Roundcube/rcube_ldap_generic.php b/program/lib/Roundcube/rcube_ldap_generic.php index 97995a5b9..c9ea824d1 100644 --- a/program/lib/Roundcube/rcube_ldap_generic.php +++ b/program/lib/Roundcube/rcube_ldap_generic.php @@ -69,6 +69,7 @@ class rcube_ldap_generic extends Net_LDAP3 if (!empty($this->config['debug'])) { rcube::write_log('ldap', $msg); } + break; case \LOG_EMERG: case \LOG_ALERT: diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php index 7ed5a0fe4..7550f39b7 100644 --- a/program/lib/Roundcube/rcube_message.php +++ b/program/lib/Roundcube/rcube_message.php @@ -210,6 +210,7 @@ class rcube_message if ($fp) { fwrite($fp, $part->body); } + return $fp ? true : $part->body; } diff --git a/program/lib/Roundcube/rcube_mime.php b/program/lib/Roundcube/rcube_mime.php index de8b606db..ee144fdbf 100644 --- a/program/lib/Roundcube/rcube_mime.php +++ b/program/lib/Roundcube/rcube_mime.php @@ -428,6 +428,7 @@ class rcube_mime } elseif ($str[$i] == '\\') { $i++; } + continue; } // separator, add to result array diff --git a/program/lib/Roundcube/rcube_plugin.php b/program/lib/Roundcube/rcube_plugin.php index 8c1b26463..8bdc09249 100644 --- a/program/lib/Roundcube/rcube_plugin.php +++ b/program/lib/Roundcube/rcube_plugin.php @@ -368,9 +368,9 @@ abstract class rcube_plugin // pattern "skins/[a-z0-9-_]+/plugins/$this->ID/" used to identify plugin resources loaded from the core skin folder if ($fn[0] != '/' && !preg_match("#^(https?://|skins/[a-z0-9-_]+/plugins/{$this->ID}/)#i", $fn)) { return $this->ID . '/' . $fn; - } else { - return $fn; } + + return $fn; } /** diff --git a/program/lib/Roundcube/rcube_plugin_api.php b/program/lib/Roundcube/rcube_plugin_api.php index 07336115d..0e1d2982d 100644 --- a/program/lib/Roundcube/rcube_plugin_api.php +++ b/program/lib/Roundcube/rcube_plugin_api.php @@ -764,8 +764,8 @@ class rcube_plugin_api // pattern "skins/" used to identify plugin resources loaded from the core skin folder if ($fn[0] != '/' && !preg_match('#^(https?://|skins/)#i', $fn)) { return $this->url . $fn; - } else { - return $fn; } + + return $fn; } } diff --git a/program/lib/Roundcube/rcube_result_thread.php b/program/lib/Roundcube/rcube_result_thread.php index d2149d01e..610b73ba7 100644 --- a/program/lib/Roundcube/rcube_result_thread.php +++ b/program/lib/Roundcube/rcube_result_thread.php @@ -294,6 +294,7 @@ class rcube_result_thread return $idx; } + return true; } diff --git a/program/lib/Roundcube/rcube_session.php b/program/lib/Roundcube/rcube_session.php index a9aec432c..526ff00da 100644 --- a/program/lib/Roundcube/rcube_session.php +++ b/program/lib/Roundcube/rcube_session.php @@ -170,9 +170,9 @@ abstract class rcube_session implements SessionHandlerInterface if ($oldvars) { $newvars = $this->fixvars($vars, $oldvars); return $this->update($key, $newvars, $oldvars); - } else { - return $this->save($key, $vars); } + + return $this->save($key, $vars); } /** @@ -541,6 +541,7 @@ abstract class rcube_session implements SessionHandlerInterface if ($level == 0) { break 2; } + break; case 'r': // reference $q += 2; @@ -553,6 +554,7 @@ abstract class rcube_session implements SessionHandlerInterface if ($level == 0) { break 2; } + break; case 's': // string $q += 2; @@ -565,6 +567,7 @@ abstract class rcube_session implements SessionHandlerInterface if ($level == 0) { break 2; } + break; case 'a': // array case 'o': // object @@ -581,6 +584,7 @@ abstract class rcube_session implements SessionHandlerInterface if (--$level == 0) { break 2; } + break; default: return false; diff --git a/program/lib/Roundcube/rcube_tnef_decoder.php b/program/lib/Roundcube/rcube_tnef_decoder.php index 19758e3ca..331f7777c 100644 --- a/program/lib/Roundcube/rcube_tnef_decoder.php +++ b/program/lib/Roundcube/rcube_tnef_decoder.php @@ -320,6 +320,7 @@ class rcube_tnef_decoder for ($i = 0; $i < $num_mval; $i++) { $value = $this->_geti($data, 32); } + break; case self::MAPI_FLOAT: case self::MAPI_ERROR: @@ -647,6 +648,7 @@ class rcube_tnef_decoder if ($ucDelta > 0) { $i += $ucDelta; } + break; case 'par': case 'page': @@ -717,6 +719,7 @@ class rcube_tnef_decoder } else { $j++; } + break; case '}': array_pop($stack); @@ -733,6 +736,7 @@ class rcube_tnef_decoder if (!empty($stack[$j]) && self::_rtfIsPlain($stack[$j])) { $document .= $c; } + break; } } diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php index f0e1847ce..534ddc2a4 100644 --- a/program/lib/Roundcube/rcube_utils.php +++ b/program/lib/Roundcube/rcube_utils.php @@ -120,41 +120,41 @@ class rcube_utils // Validate domain part if (preg_match('/^\[((IPv6:[0-9a-f:.]+)|([0-9.]+))\]$/i', $domain_part, $matches)) { return self::check_ip(preg_replace('/^IPv6:/i', '', $matches[1])); // valid IPv4 or IPv6 address - } else { - // If not an IP address - $domain_array = explode('.', $domain_part); - // Not enough parts to be a valid domain - if (count($domain_array) < 2) { + } + + // If not an IP address + $domain_array = explode('.', $domain_part); + // Not enough parts to be a valid domain + if (count($domain_array) < 2) { + return false; + } + + foreach ($domain_array as $part) { + if (!preg_match('/^((xn--)?([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]))$/', $part)) { return false; } + } - foreach ($domain_array as $part) { - if (!preg_match('/^((xn--)?([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]))$/', $part)) { - return false; - } - } + // last domain part (allow extended TLD) + $last_part = array_pop($domain_array); + if (strpos($last_part, 'xn--') !== 0 + && (preg_match('/[^a-zA-Z0-9]/', $last_part) || preg_match('/^[0-9]+$/', $last_part)) + ) { + return false; + } - // last domain part (allow extended TLD) - $last_part = array_pop($domain_array); - if (strpos($last_part, 'xn--') !== 0 - && (preg_match('/[^a-zA-Z0-9]/', $last_part) || preg_match('/^[0-9]+$/', $last_part)) - ) { - return false; - } + $rcube = rcube::get_instance(); - $rcube = rcube::get_instance(); + if (!$dns_check || !function_exists('checkdnsrr') || !$rcube->config->get('email_dns_check')) { + return true; + } - if (!$dns_check || !function_exists('checkdnsrr') || !$rcube->config->get('email_dns_check')) { + // Check DNS record(s) + // Note: We can't use ANY (#6581) + foreach (['A', 'MX', 'CNAME', 'AAAA'] as $type) { + if (checkdnsrr($domain_part, $type)) { return true; } - - // Check DNS record(s) - // Note: We can't use ANY (#6581) - foreach (['A', 'MX', 'CNAME', 'AAAA'] as $type) { - if (checkdnsrr($domain_part, $type)) { - return true; - } - } } return false; diff --git a/program/lib/Roundcube/rcube_vcard.php b/program/lib/Roundcube/rcube_vcard.php index 0f0bc46be..07a5bc934 100644 --- a/program/lib/Roundcube/rcube_vcard.php +++ b/program/lib/Roundcube/rcube_vcard.php @@ -378,6 +378,7 @@ class rcube_vcard } else { $this->raw['PHOTO'][0] = [0 => $value, 'base64' => (bool) preg_match('![^a-z0-9/=+-]!i', $value)]; } + break; case 'email': $this->raw['EMAIL'][] = [0 => $value, 'type' => array_filter(['INTERNET', $type_uc])]; @@ -390,6 +391,7 @@ class rcube_vcard $field = $typemap[strtolower($type)]; $this->raw[$field][] = [$value]; } + break; case 'birthday': case 'anniversary': @@ -397,6 +399,7 @@ class rcube_vcard $fn = self::$fieldmap[$field]; $this->raw[$fn][] = [0 => $val->format('Y-m-d'), 'value' => ['date']]; } + break; case 'address': if (!empty($this->addresstypemap[$type_uc])) { diff --git a/program/lib/Roundcube/rcube_washtml.php b/program/lib/Roundcube/rcube_washtml.php index 190c8b5b7..dcbc743df 100644 --- a/program/lib/Roundcube/rcube_washtml.php +++ b/program/lib/Roundcube/rcube_washtml.php @@ -624,6 +624,7 @@ class rcube_washtml $dump .= ''; $dump .= $this->dumpHtml($node, $level); // ignore tags not its content } + break; case \XML_CDATA_SECTION_NODE: case \XML_TEXT_NODE: