diff --git a/program/actions/contacts/edit.php b/program/actions/contacts/edit.php index a5647b6b8..5f9c47ec1 100644 --- a/program/actions/contacts/edit.php +++ b/program/actions/contacts/edit.php @@ -246,7 +246,7 @@ class rcmail_action_contacts_edit extends rcmail_action_contacts_index $rcmail->output->add_gui_object('editform', $edit_form); } - return array($form_start, $form_end); + return [$form_start, $form_end]; } /** diff --git a/program/actions/contacts/export.php b/program/actions/contacts/export.php index 028cbf551..ecf992e16 100644 --- a/program/actions/contacts/export.php +++ b/program/actions/contacts/export.php @@ -158,7 +158,7 @@ class rcmail_action_contacts_export extends rcmail_action_contacts_index // avoid unwanted casting of DateTime objects to an array // (same as in rcube_contacts::convert_save_data()) if (is_object($values) && is_a($values, 'DateTime')) { - $values = array($values); + $values = [$values]; } foreach ((array) $values as $value) { diff --git a/program/actions/contacts/group_addmembers.php b/program/actions/contacts/group_addmembers.php index 0eaffa538..06cb0ba12 100644 --- a/program/actions/contacts/group_addmembers.php +++ b/program/actions/contacts/group_addmembers.php @@ -57,7 +57,7 @@ class rcmail_action_contacts_group_addmembers extends rcmail_action_contacts_ind ($maxnum = $rcmail->config->get('max_group_members')) && ($contacts->count()->count + $num2add > $maxnum) ) { - $rcmail->output->show_message('maxgroupmembersreached', 'warning', array('max' => $maxnum)); + $rcmail->output->show_message('maxgroupmembersreached', 'warning', ['max' => $maxnum]); $rcmail->output->send(); } diff --git a/program/actions/contacts/index.php b/program/actions/contacts/index.php index e1c99cb52..2a360d80b 100644 --- a/program/actions/contacts/index.php +++ b/program/actions/contacts/index.php @@ -535,7 +535,7 @@ class rcmail_action_contacts_index extends rcmail_action $js_id = rcube::JQ($id); // set class name(s) - $classes = array('contactsearch'); + $classes = ['contactsearch']; if (!empty($source['class_name'])) { $classes[] = $source['class_name']; } diff --git a/program/actions/contacts/photo.php b/program/actions/contacts/photo.php index 1adf36dcc..1412a210d 100644 --- a/program/actions/contacts/photo.php +++ b/program/actions/contacts/photo.php @@ -56,7 +56,7 @@ class rcmail_action_contacts_photo extends rcmail_action_contacts_index if ($email = rcube_utils::get_input_value('_email', rcube_utils::INPUT_GPC)) { foreach ($rcmail->get_address_sources() as $s) { $abook = $rcmail->get_address_book($s['id']); - $result = $abook->search(array('email'), $email, 1, true, true, 'photo'); + $result = $abook->search(['email'], $email, 1, true, true, 'photo'); while ($result && ($record = $result->iterate())) { if ($record['photo']) { break 2; diff --git a/program/actions/mail/show.php b/program/actions/mail/show.php index badd7f4f6..26aa778f5 100644 --- a/program/actions/mail/show.php +++ b/program/actions/mail/show.php @@ -345,7 +345,7 @@ class rcmail_action_mail_show extends rcmail_action_mail_index $photo_img = $placeholder; } - return html::img(array('src' => $photo_img, 'alt' => $rcmail->gettext('contactphoto')) + $attrib); + return html::img(['src' => $photo_img, 'alt' => $rcmail->gettext('contactphoto')] + $attrib); } /** @@ -457,7 +457,7 @@ class rcmail_action_mail_show extends rcmail_action_mail_index $attrib['addicon'], $headers['charset'], $header_title); $ishtml = true; } - else if (in_array($hkey, array('from', 'to', 'cc', 'bcc'))) { + else if (in_array($hkey, ['from', 'to', 'cc', 'bcc'])) { $header_value = self::address_string($value, $attrib['max'], true, $attrib['addicon'], $headers['charset'], $header_title); $ishtml = true; @@ -665,7 +665,7 @@ class rcmail_action_mail_show extends rcmail_action_mail_index // Set attributes of the part container $container_class = $part->ctype_secondary == 'html' ? 'message-htmlpart' : 'message-part'; $container_id = $container_class . (++$part_no); - $container_attrib = array('class' => $container_class, 'id' => $container_id); + $container_attrib = ['class' => $container_class, 'id' => $container_id]; $body_args = [ 'safe' => $safe_mode, diff --git a/program/include/rcmail_install.php b/program/include/rcmail_install.php index aa43c7182..185f063d3 100644 --- a/program/include/rcmail_install.php +++ b/program/include/rcmail_install.php @@ -839,7 +839,7 @@ class rcmail_install } if ($isnum) { - return '[' . implode(', ', array_map(array('rcmail_install', '_dump_var'), $var)) . ']'; + return '[' . implode(', ', array_map(['rcmail_install', '_dump_var'], $var)) . ']'; } } diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php index 42f604ade..fb9e4bd74 100644 --- a/program/include/rcmail_output_html.php +++ b/program/include/rcmail_output_html.php @@ -98,7 +98,7 @@ class rcmail_output_html extends rcmail_output if ($this->devel_mode && !empty($_GET['skin']) && preg_match('/^[a-z0-9-_]+$/i', $_GET['skin'])) { if ($this->check_skin($_GET['skin'])) { $this->set_skin($_GET['skin']); - $this->app->user->save_prefs(array('skin' => $_GET['skin'])); + $this->app->user->save_prefs(['skin' => $_GET['skin']]); } } @@ -1877,7 +1877,7 @@ EOF; } if (!isset($this->script_files[$position]) || !is_array($this->script_files[$position])) { - $this->script_files[$position] = array(); + $this->script_files[$position] = []; } if (!in_array($file, $this->script_files[$position])) { @@ -2332,7 +2332,7 @@ EOF; // add oauth login button if ($this->config->get('oauth_auth_uri') && $this->config->get('oauth_provider')) { - $link_attr = array('href' => $this->app->url(['action' => 'oauth']), 'id' => 'rcmloginoauth', 'class' => 'button oauth ' . $this->config->get('oauth_provider')); + $link_attr = ['href' => $this->app->url(['action' => 'oauth']), 'id' => 'rcmloginoauth', 'class' => 'button oauth ' . $this->config->get('oauth_provider')]; $out .= html::p('oauthlogin', html::a($link_attr, $this->app->gettext(['name' => 'oauthlogin', 'vars' => ['provider' => $this->config->get('oauth_provider_name', 'OAuth')]]))); } diff --git a/program/lib/Roundcube/db/pgsql.php b/program/lib/Roundcube/db/pgsql.php index 7a9c0a99a..8c66991c3 100644 --- a/program/lib/Roundcube/db/pgsql.php +++ b/program/lib/Roundcube/db/pgsql.php @@ -212,8 +212,8 @@ class rcube_db_pgsql extends rcube_db } $table = $this->table_name($table, true); - $columns = array_map(array($this, 'quote_identifier'), $columns); - $target = implode(', ', array_map(array($this, 'quote_identifier'), array_keys($keys))); + $columns = array_map([$this, 'quote_identifier'], $columns); + $target = implode(', ', array_map([$this, 'quote_identifier'], array_keys($keys))); $cols = $target . ', ' . implode(', ', $columns); $vals = implode(', ', array_map(function($i) { return $this->quote($i); }, $keys)); $vals .= ', ' . rtrim(str_repeat('?, ', count($columns)), ', '); diff --git a/program/lib/Roundcube/html.php b/program/lib/Roundcube/html.php index 546c4f731..aa85dae29 100644 --- a/program/lib/Roundcube/html.php +++ b/program/lib/Roundcube/html.php @@ -658,13 +658,13 @@ class html_textarea extends html * Builder for HTML drop-down menus * Syntax:
* // create instance. arguments are used to set attributes of select-tag
- * $select = new html_select(array('name' => 'fieldname'));
+ * $select = new html_select(['name' => 'fieldname']);
*
* // add one option
* $select->add('Switzerland', 'CH');
*
* // add multiple options
- * $select->add(array('Switzerland','Germany'), array('CH','DE'));
+ * $select->add(['Switzerland','Germany'], ['CH','DE']);
*
* // generate pulldown with selection 'Switzerland' and return html-code
* // as second argument the same attributes available to instantiate can be used
diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php
index 817824ae6..6ba90802f 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -1194,7 +1194,7 @@ class rcube
*
* @return string Output of command. Shell errors not detectable
*/
- public static function exec(/* $cmd, $values1 = array(), ... */)
+ public static function exec(/* $cmd, $values1 = [], ... */)
{
$args = func_get_args();
$cmd = array_shift($args);
@@ -1658,7 +1658,7 @@ class rcube
// Try to find FQDN, some spamfilters doesn't like 'localhost' (#1486924)
if (!preg_match('/\.[a-z0-9-]+$/i', $domain_part)) {
- foreach (array($_SERVER['HTTP_HOST'], $_SERVER['SERVER_NAME']) as $host) {
+ foreach ([$_SERVER['HTTP_HOST'], $_SERVER['SERVER_NAME']] as $host) {
$host = preg_replace('/:[0-9]+$/', '', $host);
if ($host && preg_match('/\.[a-z]+$/i', $host)) {
$domain_part = $host;
diff --git a/program/lib/Roundcube/rcube_charset.php b/program/lib/Roundcube/rcube_charset.php
index 311ba20ce..bdb05bbc4 100644
--- a/program/lib/Roundcube/rcube_charset.php
+++ b/program/lib/Roundcube/rcube_charset.php
@@ -292,7 +292,7 @@ class rcube_charset
// throw an exception if mbstring reports an illegal character in input
// using mb_check_encoding() is much slower
- set_error_handler(array('rcube_charset', 'error_handler'), E_WARNING);
+ set_error_handler(['rcube_charset', 'error_handler'], E_WARNING);
try {
$out = mb_convert_encoding($str, $to, $from);
}
diff --git a/program/lib/Roundcube/rcube_contacts.php b/program/lib/Roundcube/rcube_contacts.php
index 47a45587e..2cb7d8935 100644
--- a/program/lib/Roundcube/rcube_contacts.php
+++ b/program/lib/Roundcube/rcube_contacts.php
@@ -347,7 +347,7 @@ class rcube_contacts extends rcube_addressbook
}
else {
// require each word in to be present in one of the fields
- $words = ($mode & rcube_addressbook::SEARCH_STRICT) ? array($value) : rcube_utils::tokenize_string($value, 1);
+ $words = ($mode & rcube_addressbook::SEARCH_STRICT) ? [$value] : rcube_utils::tokenize_string($value, 1);
foreach ($words as $word) {
$groups = [];
foreach ((array) $fields as $idx => $col) {
diff --git a/program/lib/Roundcube/rcube_csv2vcard.php b/program/lib/Roundcube/rcube_csv2vcard.php
index 9baf0ed64..d8c5c25d2 100644
--- a/program/lib/Roundcube/rcube_csv2vcard.php
+++ b/program/lib/Roundcube/rcube_csv2vcard.php
@@ -647,7 +647,7 @@ class rcube_csv2vcard
}
// Empty dates, e.g. "0/0/00", "0000-00-00 00:00:00"
- foreach (array('birthday', 'anniversary') as $key) {
+ foreach (['birthday', 'anniversary'] as $key) {
if (!empty($contact[$key])) {
$date = preg_replace('/[0[:^word:]]/', '', $contact[$key]);
if (empty($date)) {
diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php
index 644f35543..d95843403 100644
--- a/program/lib/Roundcube/rcube_db.php
+++ b/program/lib/Roundcube/rcube_db.php
@@ -1326,7 +1326,7 @@ class rcube_db
$opts = explode('&', $dsn);
}
else { // database?param1=value1
- $opts = array($dsn);
+ $opts = [$dsn];
}
foreach ($opts as $opt) {
list($key, $value) = explode('=', $opt);
diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php
index 4265ebc7b..8ed2e6d84 100644
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -2186,7 +2186,7 @@ class rcube_imap extends rcube_storage
// get message/rfc822's child-parts
if (is_array($part[8]) && $di != 8) {
- $struct->parts = array();
+ $struct->parts = [];
for ($i=0, $count=0; $iget_capability('QRESYNC') || $this->get_capability('CONDSTORE'))
) {
- if ($add_data = $this->conn->status($folder, array('HIGHESTMODSEQ'))) {
+ if ($add_data = $this->conn->status($folder, ['HIGHESTMODSEQ'])) {
$data = array_merge($data, $add_data);
}
}
diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php
index 18ee54a3d..6eca2b96e 100644
--- a/program/lib/Roundcube/rcube_imap_generic.php
+++ b/program/lib/Roundcube/rcube_imap_generic.php
@@ -2158,7 +2158,7 @@ class rcube_imap_generic
if ($mode == 1 && $index_field == 'DATE') {
if (preg_match('/BODY\[HEADER\.FIELDS \("*DATE"*\)\] (.*)/', $line, $matches)) {
- $value = preg_replace(array('/^"*[a-z]+:/i'), '', $matches[1]);
+ $value = preg_replace(['/^"*[a-z]+:/i'], '', $matches[1]);
$value = trim($value);
$result[$id] = rcube_utils::strtotime($value);
}
diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php
index dc4b2f096..d1edda85d 100644
--- a/program/lib/Roundcube/rcube_ldap.php
+++ b/program/lib/Roundcube/rcube_ldap.php
@@ -179,12 +179,12 @@ class rcube_ldap extends rcube_addressbook
// support for composite address
if (!empty($this->coltypes['street']) && !empty($this->coltypes['locality'])) {
- $this->coltypes['address'] = array(
+ $this->coltypes['address'] = [
'limit' => max(1, $this->coltypes['locality']['limit'] + $this->coltypes['address']['limit']),
'subtypes' => array_merge((array)$this->coltypes['address']['subtypes'], (array)$this->coltypes['locality']['subtypes']),
'childs' => [],
'attributes' => [],
- ) + (array)$this->coltypes['address'];
+ ] + (array)$this->coltypes['address'];
foreach (['street','locality','zipcode','region','country'] as $childcol) {
if ($this->coltypes[$childcol]) {
@@ -676,7 +676,7 @@ class rcube_ldap extends rcube_addressbook
$attrs = [];
foreach ((array) $entry['objectclass'] as $objectclass) {
- if (($member_attr = $this->get_group_member_attr(array($objectclass), ''))
+ if (($member_attr = $this->get_group_member_attr([$objectclass], ''))
&& ($member_attr = strtolower($member_attr)) && !in_array($member_attr, $attrs)
) {
$members = $this->_list_group_members($dn, $entry, $member_attr, $count);
@@ -1036,7 +1036,7 @@ class rcube_ldap extends rcube_addressbook
$name_attr = $this->prop['groups']['name_attr'];
$email_attr = $this->prop['groups']['email_attr'] ?: 'mail';
- $attrs = array_unique(array('dn', 'objectClass', $name_attr, $email_attr));
+ $attrs = array_unique(['dn', 'objectClass', $name_attr, $email_attr]);
$res = $this->ldap->search($this->groups_base_dn, $filter, $this->prop['groups']['scope'], $attrs, $prop, $count);
@@ -1349,7 +1349,7 @@ class rcube_ldap extends rcube_addressbook
if (!in_array($fld, $this->prop['required_fields'])) {
// ...It is not, safe to clear.
// #1488420: Workaround "ldap_mod_del(): Modify: Inappropriate matching in..."
- // jpegPhoto attribute require an array() here. It looks to me that it works for other attribs too
+ // jpegPhoto attribute require an array here. It looks to me that it works for other attribs too
$deletedata[$fld] = [];
//$deletedata[$fld] = $old_data[$fld];
}
@@ -1691,7 +1691,7 @@ class rcube_ldap extends rcube_addressbook
foreach ($colprop['serialized'] as $subtype => $delim) {
$key = $col.':'.$subtype;
foreach ((array)$save_cols[$key] as $i => $val) {
- $values = array($val['street'], $val['locality'], $val['zipcode'], $val['country']);
+ $values = [$val['street'], $val['locality'], $val['zipcode'], $val['country']];
$save_cols[$key][$i] = count(array_filter($values)) ? implode($delim, $values) : null;
}
}
diff --git a/program/lib/Roundcube/rcube_ldap_generic.php b/program/lib/Roundcube/rcube_ldap_generic.php
index 1e779c95b..f696566f5 100644
--- a/program/lib/Roundcube/rcube_ldap_generic.php
+++ b/program/lib/Roundcube/rcube_ldap_generic.php
@@ -294,7 +294,7 @@ class rcube_ldap_generic extends Net_LDAP3
if ($entry[$attr]['count'] == 1) {
switch ($attr) {
case 'objectclass':
- $rec[$attr] = array(strtolower($entry[$attr][0]));
+ $rec[$attr] = [strtolower($entry[$attr][0])];
break;
default:
$rec[$attr] = $entry[$attr][0];
diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php
index 20a09d46c..92992c0a2 100644
--- a/program/lib/Roundcube/rcube_message.php
+++ b/program/lib/Roundcube/rcube_message.php
@@ -875,7 +875,7 @@ class rcube_message
}
if ($mail_part->headers['content-id']) {
- $mail_part->content_id = preg_replace(array('/^', '/>$/'), '', $mail_part->headers['content-id']);
+ $mail_part->content_id = preg_replace(['/^', '/>$/'], '', $mail_part->headers['content-id']);
}
if ($mail_part->headers['content-location']) {
@@ -924,7 +924,7 @@ class rcube_message
// if this is a related part try to resolve references
// Note: mixed is not supposed to contain inline images, but we've found such examples (#5905)
if (preg_match('/^multipart\/(related|relative|mixed)/', $mimetype) && count($this->inline_parts)) {
- $a_replaces = array();
+ $a_replaces = [];
$img_regexp = '/^image\/(gif|jpe?g|png|tiff|bmp|svg)/';
foreach ($this->inline_parts as $inline_object) {
diff --git a/program/lib/Roundcube/rcube_mime_decode.php b/program/lib/Roundcube/rcube_mime_decode.php
index 9f7f11f23..c9695d791 100644
--- a/program/lib/Roundcube/rcube_mime_decode.php
+++ b/program/lib/Roundcube/rcube_mime_decode.php
@@ -107,7 +107,7 @@ class rcube_mime_decode
$header_name = strtolower($value['name']);
if (isset($return->headers[$header_name]) && !is_array($return->headers[$header_name])) {
- $return->headers[$header_name] = array($return->headers[$header_name]);
+ $return->headers[$header_name] = [$return->headers[$header_name]];
$return->headers[$header_name][] = $value['value'];
}
else if (isset($return->headers[$header_name])) {
diff --git a/program/lib/Roundcube/rcube_output.php b/program/lib/Roundcube/rcube_output.php
index 0440b890f..aea09dddd 100644
--- a/program/lib/Roundcube/rcube_output.php
+++ b/program/lib/Roundcube/rcube_output.php
@@ -31,8 +31,8 @@ abstract class rcube_output
protected $app;
protected $config;
protected $charset = RCUBE_CHARSET;
- protected $env = array();
- protected $skins = array();
+ protected $env = [];
+ protected $skins = [];
/**
@@ -82,8 +82,8 @@ abstract class rcube_output
/**
* Set environment variable
*
- * @param string $name Property name
- * @param mixed $value Property value
+ * @param string $name Property name
+ * @param mixed $value Property value
*/
public function set_env($name, $value)
{
@@ -93,7 +93,7 @@ abstract class rcube_output
/**
* Environment variable getter.
*
- * @param string $name Property name
+ * @param string $name Property name
*
* @return mixed Property value
*/
@@ -107,7 +107,7 @@ abstract class rcube_output
*/
public function reset()
{
- $this->env = array();
+ $this->env = [];
}
/**
@@ -116,7 +116,7 @@ abstract class rcube_output
* @param string $message Message to display
* @param string $type Message type [notice|confirm|error]
* @param array $vars Key-value pairs to be replaced in localized text
- * @param boolean $override Override last set message
+ * @param bool $override Override last set message
* @param int $timeout Message displaying time in seconds
*/
abstract function show_message($message, $type = 'notice', $vars = null, $override = true, $timeout = 0);
@@ -124,10 +124,10 @@ abstract class rcube_output
/**
* Redirect to a certain url.
*
- * @param mixed $p Either a string with the action or url parameters as key-value pairs
- * @param int $delay Delay in seconds
+ * @param array|string $p Either a string with the action or url parameters as key-value pairs
+ * @param int $delay Delay in seconds
*/
- abstract function redirect($p = array(), $delay = 1);
+ abstract function redirect($p = [], $delay = 1);
/**
* Send output to the client.
@@ -184,7 +184,7 @@ abstract class rcube_output
return;
}
- $headers = array();
+ $headers = [];
// Unlock IE compatibility mode
if ($this->browser->ie) {
@@ -204,7 +204,7 @@ abstract class rcube_output
$headers['X-Frame-Options'] = $xframe;
}
- $plugin = $this->app->plugins->exec_hook('common_headers', array('headers' => $headers, 'privacy' => $privacy));
+ $plugin = $this->app->plugins->exec_hook('common_headers', ['headers' => $headers, 'privacy' => $privacy]);
foreach ($plugin['headers'] as $header => $value) {
header("$header: $value");
@@ -223,7 +223,7 @@ abstract class rcube_output
* type_charset - Content character set
* time_limit - Script execution limit (default: 3600)
*/
- public function download_headers($filename, $params = array())
+ public function download_headers($filename, $params = [])
{
if (empty($params['disposition'])) {
$params['disposition'] = 'attachment';
@@ -246,7 +246,10 @@ abstract class rcube_output
$disposition .= sprintf("; filename=\"%s\"", $filename);
}
else {
- $disposition .= sprintf("; filename*=%s''%s", $params['charset'] ?: $this->charset, rawurlencode($filename));
+ $disposition .= sprintf("; filename*=%s''%s",
+ !empty($params['charset']) ? $params['charset'] : $this->charset,
+ rawurlencode($filename)
+ );
}
header($disposition);
@@ -281,27 +284,29 @@ abstract class rcube_output
/**
* Create an edit field for inclusion on a form
*
- * @param string $col Field name
+ * @param string $name Field name
* @param string $value Field value
* @param array $attrib HTML element attributes for the field
* @param string $type HTML element type (default 'text')
*
* @return string HTML field definition
*/
- public static function get_edit_field($col, $value, $attrib, $type = 'text')
+ public static function get_edit_field($name, $value, $attrib = [], $type = 'text')
{
- static $colcounts = array();
+ static $colcounts = [];
- $fname = '_' . $col;
+ $fname = '_' . $name;
$attrib['name'] = $fname . (!empty($attrib['array']) ? '[]' : '');
- $attrib['class'] = trim((!empty($attrib['class']) ? $attrib['class'] : '') . ' ff_' . $col);
+ $attrib['class'] = trim((!empty($attrib['class']) ? $attrib['class'] : '') . ' ff_' . $name);
if ($type == 'checkbox') {
$attrib['value'] = '1';
$input = new html_checkbox($attrib);
}
else if ($type == 'textarea') {
- $attrib['cols'] = $attrib['size'];
+ if (!empty($attrib['size'])) {
+ $attrib['cols'] = $attrib['size'];
+ }
$input = new html_textarea($attrib);
}
else if ($type == 'select') {
@@ -309,7 +314,9 @@ abstract class rcube_output
if (empty($attrib['skip-empty'])) {
$input->add('---', '');
}
- $input->add(array_values($attrib['options']), array_keys($attrib['options']));
+ if (!empty($attrib['options'])) {
+ $input->add(array_values($attrib['options']), array_keys($attrib['options']));
+ }
}
else if ($type == 'password' || (isset($attrib['type']) && $attrib['type'] == 'password')) {
$input = new html_passwordfield($attrib);
@@ -324,7 +331,7 @@ abstract class rcube_output
// use value from post
if (isset($_POST[$fname])) {
$postvalue = rcube_utils::get_input_value($fname, rcube_utils::INPUT_POST, true);
- $value = !empty($attrib['array']) ? $postvalue[intval($colcounts[$col]++)] : $postvalue;
+ $value = !empty($attrib['array']) ? $postvalue[intval($colcounts[$name]++)] : $postvalue;
}
return $input->show($value);
@@ -333,9 +340,9 @@ abstract class rcube_output
/**
* Convert a variable into a javascript object notation
*
- * @param mixed $input Input value
- * @param boolean $pretty Enable JSON formatting
- * @param boolean $inline Enable inline mode (generates output safe for use inside HTML)
+ * @param mixed $input Input value
+ * @param bool $pretty Enable JSON formatting
+ * @param bool $inline Enable inline mode (generates output safe for use inside HTML)
*
* @return string Serialized JSON string
*/
diff --git a/program/lib/Roundcube/rcube_plugin_api.php b/program/lib/Roundcube/rcube_plugin_api.php
index c5ce0a67d..d7de956be 100644
--- a/program/lib/Roundcube/rcube_plugin_api.php
+++ b/program/lib/Roundcube/rcube_plugin_api.php
@@ -438,8 +438,8 @@ class rcube_plugin_api
/**
* Allows a plugin object to register a callback for a certain hook
*
- * @param string $hook Hook name
- * @param mixed $callback String with global function name or array($obj, 'methodname')
+ * @param string $hook Hook name
+ * @param callback $callback A callback function
*/
public function register_hook($hook, $callback)
{
@@ -468,8 +468,8 @@ class rcube_plugin_api
/**
* Allow a plugin object to unregister a callback.
*
- * @param string $hook Hook name
- * @param mixed $callback String with global function name or array($obj, 'methodname')
+ * @param string $hook Hook name
+ * @param callback $callback A callback function
*/
public function unregister_hook($hook, $callback)
{
@@ -526,18 +526,20 @@ class rcube_plugin_api
/**
* Let a plugin register a handler for a specific request
*
- * @param string $action Action name (_task=mail&_action=plugin.foo)
- * @param string $owner Plugin name that registers this action
- * @param mixed $callback Callback: string with global function name or array($obj, 'methodname')
- * @param string $task Task name registered by this plugin
+ * @param string $action Action name (_task=mail&_action=plugin.foo)
+ * @param string $owner Plugin name that registers this action
+ * @param callback $callback A callback function
+ * @param string $task Task name registered by this plugin
*/
public function register_action($action, $owner, $callback, $task = null)
{
// check action name
- if ($task)
+ if ($task) {
$action = $task.'.'.$action;
- else if (strpos($action, 'plugin.') !== 0)
+ }
+ else if (strpos($action, 'plugin.') !== 0) {
$action = 'plugin.'.$action;
+ }
// can register action only if it's not taken or registered by myself
if (!isset($this->actionmap[$action]) || $this->actionmap[$action] == $owner) {
@@ -545,10 +547,12 @@ class rcube_plugin_api
$this->actionmap[$action] = $owner;
}
else {
- rcube::raise_error(array('code' => 523, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
- 'message' => "Cannot register action $action;"
- ." already taken by another plugin"), true, false);
+ rcube::raise_error([
+ 'code' => 523, 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Cannot register action $action; already taken by another plugin"
+ ],
+ true, false
+ );
}
}
@@ -576,9 +580,9 @@ class rcube_plugin_api
/**
* Register a handler function for template objects
*
- * @param string $name Object name
- * @param string $owner Plugin name that registers this action
- * @param mixed $callback Callback: string with global function name or array($obj, 'methodname')
+ * @param string $name Object name
+ * @param string $owner Plugin name that registers this action
+ * @param callback $callback A callback function
*/
public function register_handler($name, $owner, $callback)
{
diff --git a/program/lib/Roundcube/rcube_storage.php b/program/lib/Roundcube/rcube_storage.php
index 8d1ac64d1..c1818f1a2 100644
--- a/program/lib/Roundcube/rcube_storage.php
+++ b/program/lib/Roundcube/rcube_storage.php
@@ -613,7 +613,7 @@ abstract class rcube_storage
}
}
- return array($uids, $all);
+ return [$uids, $all];
}
diff --git a/program/lib/Roundcube/rcube_string_replacer.php b/program/lib/Roundcube/rcube_string_replacer.php
index f42479e34..1f6f40ec0 100644
--- a/program/lib/Roundcube/rcube_string_replacer.php
+++ b/program/lib/Roundcube/rcube_string_replacer.php
@@ -31,10 +31,10 @@ class rcube_string_replacer
public $linkref_index;
public $linkref_pattern;
- protected $values = array();
- protected $options = array();
- protected $linkrefs = array();
- protected $urls = array();
+ protected $values = [];
+ protected $options = [];
+ protected $linkrefs = [];
+ protected $urls = [];
protected $noword = '[^\w@.#-]';
@@ -43,7 +43,7 @@ class rcube_string_replacer
*
* @param array $options Configuration options
*/
- function __construct($options = array())
+ function __construct($options = [])
{
// Simplified domain expression for UTF8 characters handling
// Support unicode/punycode in top-level domain part
@@ -201,11 +201,11 @@ class rcube_string_replacer
public function replace($str)
{
// search for patterns like links and e-mail addresses
- $str = preg_replace_callback($this->link_pattern, array($this, 'link_callback'), $str);
- $str = preg_replace_callback($this->mailto_pattern, array($this, 'mailto_callback'), $str);
+ $str = preg_replace_callback($this->link_pattern, [$this, 'link_callback'], $str);
+ $str = preg_replace_callback($this->mailto_pattern, [$this, 'mailto_callback'], $str);
// resolve link references
- $str = preg_replace_callback($this->linkref_index, array($this, 'linkref_addindex'), $str);
- $str = preg_replace_callback($this->linkref_pattern, array($this, 'linkref_callback'), $str);
+ $str = preg_replace_callback($this->linkref_index, [$this, 'linkref_addindex'], $str);
+ $str = preg_replace_callback($this->linkref_pattern, [$this, 'linkref_callback'], $str);
return $str;
}
@@ -219,7 +219,7 @@ class rcube_string_replacer
*/
public function resolve($str)
{
- return preg_replace_callback(self::$pattern, array($this, 'replace_callback'), $str);
+ return preg_replace_callback(self::$pattern, [$this, 'replace_callback'], $str);
}
/**
@@ -245,13 +245,15 @@ class rcube_string_replacer
$in = false;
for ($i=0, $len=strlen($url); $i<$len; $i++) {
if ($url[$i] == '[') {
- if ($in)
+ if ($in) {
break;
+ }
$in = true;
}
else if ($url[$i] == ']') {
- if (!$in)
+ if (!$in) {
break;
+ }
$in = false;
}
}
@@ -267,13 +269,15 @@ class rcube_string_replacer
$in = false;
for ($i=0, $len=strlen($url); $i<$len; $i++) {
if ($url[$i] == '(') {
- if ($in)
+ if ($in) {
break;
+ }
$in = true;
}
else if ($url[$i] == ')') {
- if (!$in)
+ if (!$in) {
break;
+ }
$in = false;
}
}
diff --git a/program/lib/Roundcube/rcube_text2html.php b/program/lib/Roundcube/rcube_text2html.php
index 1e8121f62..f35153859 100644
--- a/program/lib/Roundcube/rcube_text2html.php
+++ b/program/lib/Roundcube/rcube_text2html.php
@@ -32,7 +32,7 @@ class rcube_text2html
protected $text;
/** @var array Configuration */
- protected $config = array(
+ protected $config = [
// non-breaking space
'space' => "\xC2\xA0",
// enables format=flowed parser
@@ -53,7 +53,7 @@ class rcube_text2html
// prefix and suffix of unwrappable line
'nobr_start' => '',
'nobr_end' => '',
- );
+ ];
/** @var bool Internal state */
protected $_converted = false;
@@ -70,7 +70,7 @@ class rcube_text2html
* @param bool $from_file Indicates $source is a file to pull content from
* @param array $config Class configuration
*/
- function __construct($source = '', $from_file = false, $config = array())
+ function __construct($source = '', $from_file = false, $config = [])
{
if (!empty($source)) {
$this->set_text($source, $from_file);
@@ -141,7 +141,7 @@ class rcube_text2html
protected function _converter($text)
{
// make links and email-addresses clickable
- $attribs = array('link_attribs' => array('rel' => 'noreferrer', 'target' => '_blank'));
+ $attribs = ['link_attribs' => ['rel' => 'noreferrer', 'target' => '_blank']];
$replacer = new $this->config['replacer']($attribs);
if ($this->config['flowed']) {
diff --git a/program/lib/Roundcube/rcube_tnef_decoder.php b/program/lib/Roundcube/rcube_tnef_decoder.php
index accc87240..47ee1db6a 100644
--- a/program/lib/Roundcube/rcube_tnef_decoder.php
+++ b/program/lib/Roundcube/rcube_tnef_decoder.php
@@ -135,8 +135,8 @@ class rcube_tnef_decoder
*/
public function decompress($data)
{
- $attachments = array();
- $message = array();
+ $attachments = [];
+ $message = [];
if ($this->_geti($data, 32) == self::SIGNATURE) {
$this->_geti($data, 16);
@@ -160,10 +160,10 @@ class rcube_tnef_decoder
}
}
- return array(
+ return [
'message' => $message,
'attachments' => array_reverse($attachments),
- );
+ ];
}
/**
@@ -425,12 +425,12 @@ class rcube_tnef_decoder
case self::ARENDDATA:
// Add a new default data block to hold details of this
// attachment. Reverse order is easier to handle later!
- array_unshift($attachment, array(
+ array_unshift($attachment, [
'type' => 'application',
'subtype' => 'octet-stream',
'name' => 'unknown',
'stream' => ''
- ));
+ ]);
break;
@@ -547,7 +547,7 @@ class rcube_tnef_decoder
public static function rtf2text($text)
{
$document = '';
- $stack = array();
+ $stack = [];
$j = -1;
// Read the data character-by- character…
@@ -746,7 +746,7 @@ class rcube_tnef_decoder
*/
protected static function _rtfIsPlain($s)
{
- $notPlain = array('*', 'fonttbl', 'colortbl', 'datastore', 'themedata', 'stylesheet');
+ $notPlain = ['*', 'fonttbl', 'colortbl', 'datastore', 'themedata', 'stylesheet'];
for ($i = 0; $i < count($notPlain); $i++) {
if (!empty($s[$notPlain[$i]])) {
diff --git a/program/lib/Roundcube/rcube_user.php b/program/lib/Roundcube/rcube_user.php
index c51bd2a4f..eb431d1c0 100644
--- a/program/lib/Roundcube/rcube_user.php
+++ b/program/lib/Roundcube/rcube_user.php
@@ -47,7 +47,7 @@ class rcube_user
private $rc;
/** @var array Internal identities cache */
- private $identities = array();
+ private $identities = [];
/** @var array Internal emails cache */
private $emails;
@@ -71,12 +71,14 @@ class rcube_user
if ($id && !$sql_arr) {
$sql_result = $this->db->query(
"SELECT * FROM " . $this->db->table_name('users', true)
- . " WHERE `user_id` = ?", $id);
+ . " WHERE `user_id` = ?", $id
+ );
+
$sql_arr = $this->db->fetch_assoc($sql_result);
}
if (!empty($sql_arr)) {
- $this->ID = $sql_arr['user_id'];
+ $this->ID = (int) $sql_arr['user_id'];
$this->data = $sql_arr;
$this->language = $sql_arr['language'];
}
@@ -91,13 +93,13 @@ class rcube_user
*/
function get_username($part = null)
{
- if ($this->data['username']) {
+ if (!empty($this->data['username'])) {
// return real name
if (!$part) {
return $this->data['username'];
}
- list($local, $domain) = explode('@', $this->data['username']);
+ list($local, $domain) = rcube_utils::explode('@', $this->data['username']);
// at least we should always have the local part
if ($part == 'local') {
@@ -131,10 +133,11 @@ class rcube_user
return $this->prefs;
}
- $this->prefs = array();
+ $this->prefs = [];
- if (!empty($this->language))
+ if (!empty($this->language)) {
$this->prefs['language'] = $this->language;
+ }
if ($this->ID) {
// Preferences from session (write-master is unavailable)
@@ -152,7 +155,7 @@ class rcube_user
}
if ($this->data['preferences']) {
- $this->prefs += (array)unserialize($this->data['preferences']);
+ $this->prefs += (array) unserialize($this->data['preferences']);
}
}
@@ -165,7 +168,7 @@ class rcube_user
* @param array $a_user_prefs User prefs to save
* @param bool $no_session Simplified language/preferences handling
*
- * @return boolean True on success, False on failure
+ * @return bool True on success, False on failure
*/
function save_prefs($a_user_prefs, $no_session = false)
{
@@ -181,11 +184,11 @@ class rcube_user
return true;
}
- $plugin = $this->rc->plugins->exec_hook('preferences_update', array(
+ $plugin = $this->rc->plugins->exec_hook('preferences_update', [
'userid' => $this->ID,
'prefs' => $a_user_prefs,
'old' => (array)$this->get_prefs()
- ));
+ ]);
if (!empty($plugin['abort'])) {
return false;
@@ -218,7 +221,8 @@ class rcube_user
" WHERE `user_id` = ?",
$save_prefs,
$this->language,
- $this->ID);
+ $this->ID
+ );
// Update success
if ($this->db->affected_rows() !== false) {
@@ -251,7 +255,7 @@ class rcube_user
}
/**
- * Generate a unique hash to identify this user whith
+ * Generate a unique hash to identify this user with
*/
function get_hash()
{
@@ -260,7 +264,7 @@ class rcube_user
// generate a random hash and store it in user prefs
if (empty($prefs['client_hash'])) {
$prefs['client_hash'] = rcube_utils::random_bytes(16);
- $this->save_prefs(array('client_hash' => $prefs['client_hash']));
+ $this->save_prefs(['client_hash' => $prefs['client_hash']]);
}
return $prefs['client_hash'];
@@ -271,19 +275,20 @@ class rcube_user
*
* @param bool $default Return only default identity
*
- * @return array List of emails (identity_id, name, email)
+ * @return array List of emails (identity_id, name, email) or single email-data
*/
function list_emails($default = false)
{
if ($this->emails === null) {
- $this->emails = array();
+ $this->emails = [];
$sql_result = $this->db->query(
"SELECT `identity_id`, `name`, `email`"
." FROM " . $this->db->table_name('identities', true)
." WHERE `user_id` = ? AND `del` <> 1"
." ORDER BY `standard` DESC, `name` ASC, `email` ASC, `identity_id` ASC",
- $this->ID);
+ $this->ID
+ );
while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
$this->emails[] = $sql_arr;
@@ -302,7 +307,8 @@ class rcube_user
*/
function get_identity($id = null)
{
- $id = (int)$id;
+ $id = (int) $id;
+
// cache identities for better performance
if (!array_key_exists($id, $this->identities)) {
$result = $this->list_identities($id ? "AND `identity_id` = $id" : '');
@@ -322,14 +328,14 @@ class rcube_user
*/
function list_identities($sql_add = '', $formatted = false)
{
- $result = array();
+ $result = [];
$sql_result = $this->db->query(
- "SELECT * FROM ".$this->db->table_name('identities', true).
- " WHERE `del` <> 1 AND `user_id` = ?".
- ($sql_add ? " ".$sql_add : "").
- " ORDER BY `standard` DESC, `name` ASC, `email` ASC, `identity_id` ASC",
- $this->ID);
+ "SELECT * FROM ".$this->db->table_name('identities', true)
+ . " WHERE `del` <> 1 AND `user_id` = ?" . ($sql_add ? " $sql_add" : "")
+ . " ORDER BY `standard` DESC, `name` ASC, `email` ASC, `identity_id` ASC",
+ $this->ID
+ );
while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
if ($formatted) {
@@ -353,7 +359,7 @@ class rcube_user
* @param int $iid Identity ID
* @param array $data Hash array with col->value pairs to save
*
- * @return boolean True if saved successfully, false if nothing changed
+ * @return bool True if saved successfully, false if nothing changed
*/
function update_identity($iid, $data)
{
@@ -361,9 +367,9 @@ class rcube_user
return false;
}
- $query_cols = $query_params = array();
+ $query_cols = $query_params = [];
- foreach ((array)$data as $col => $value) {
+ foreach ((array) $data as $col => $value) {
$query_cols[] = $this->db->quote_identifier($col) . ' = ?';
$query_params[] = $value;
}
@@ -371,16 +377,15 @@ class rcube_user
$query_params[] = $this->ID;
$sql = "UPDATE ".$this->db->table_name('identities', true).
- " SET `changed` = ".$this->db->now().", ".implode(', ', $query_cols).
- " WHERE `identity_id` = ?".
- " AND `user_id` = ?".
- " AND `del` <> 1";
+ " SET `changed` = ".$this->db->now() . ", " . implode(', ', $query_cols)
+ . " WHERE `identity_id` = ?"
+ . " AND `user_id` = ?"
+ . " AND `del` <> 1";
- call_user_func_array(array($this->db, 'query'),
- array_merge(array($sql), $query_params));
+ $this->db->query($sql, $query_params);
// clear the cache
- $this->identities = array();
+ $this->identities = [];
$this->emails = null;
return $this->db->affected_rows() > 0;
@@ -391,7 +396,7 @@ class rcube_user
*
* @param array $data Hash array with col->value pairs to save
*
- * @return int The inserted identity ID or false on error
+ * @return int|false The inserted identity ID or false on error
*/
function insert_identity($data)
{
@@ -401,10 +406,10 @@ class rcube_user
unset($data['user_id']);
- $insert_cols = array();
- $insert_values = array();
+ $insert_cols = [];
+ $insert_values = [];
- foreach ((array)$data as $col => $value) {
+ foreach ((array) $data as $col => $value) {
$insert_cols[] = $this->db->quote_identifier($col);
$insert_values[] = $value;
}
@@ -412,14 +417,14 @@ class rcube_user
$insert_cols[] = $this->db->quote_identifier('user_id');
$insert_values[] = $this->ID;
- $sql = "INSERT INTO ".$this->db->table_name('identities', true).
- " (`changed`, ".implode(', ', $insert_cols).")".
- " VALUES (".$this->db->now().", ".implode(', ', array_pad(array(), count($insert_values), '?')).")";
+ $sql = "INSERT INTO " . $this->db->table_name('identities', true)
+ . " (`changed`, " . implode(', ', $insert_cols) . ")"
+ . " VALUES (" . $this->db->now() . ", " . implode(', ', array_pad([], count($insert_values), '?')) . ")";
$insert = $this->db->query($sql, $insert_values);
// clear the cache
- $this->identities = array();
+ $this->identities = [];
$this->emails = null;
return $this->db->affected_rows($insert) ? $this->db->insert_id('identities') : false;
@@ -430,7 +435,7 @@ class rcube_user
*
* @param int $iid Identity ID
*
- * @return boolean True if deleted successfully, false if nothing changed
+ * @return bool True if deleted successfully, false if nothing changed
*/
function delete_identity($iid)
{
@@ -439,9 +444,10 @@ class rcube_user
}
$sql_result = $this->db->query(
- "SELECT count(*) AS ident_count FROM ".$this->db->table_name('identities', true).
- " WHERE `user_id` = ? AND `del` <> 1",
- $this->ID);
+ "SELECT count(*) AS ident_count FROM " . $this->db->table_name('identities', true)
+ . " WHERE `user_id` = ? AND `del` <> 1",
+ $this->ID
+ );
$sql_arr = $this->db->fetch_assoc($sql_result);
@@ -451,15 +457,15 @@ class rcube_user
}
$this->db->query(
- "UPDATE ".$this->db->table_name('identities', true).
- " SET `del` = 1, `changed` = ".$this->db->now().
- " WHERE `user_id` = ?".
- " AND `identity_id` = ?",
+ "UPDATE " . $this->db->table_name('identities', true)
+ . " SET `del` = 1, `changed` = " . $this->db->now()
+ . " WHERE `user_id` = ? AND `identity_id` = ?",
$this->ID,
- $iid);
+ $iid
+ );
// clear the cache
- $this->identities = array();
+ $this->identities = [];
$this->emails = null;
return $this->db->affected_rows() > 0;
@@ -474,13 +480,22 @@ class rcube_user
{
if ($this->ID && $iid) {
$this->db->query(
- "UPDATE ".$this->db->table_name('identities', true).
- " SET `standard` = '0'".
- " WHERE `user_id` = ? AND `identity_id` <> ?",
+ "UPDATE " . $this->db->table_name('identities', true)
+ . " SET `standard` = '0'"
+ . " WHERE `user_id` = ? AND `identity_id` <> ?",
$this->ID,
- $iid);
+ $iid
+ );
- unset($this->identities[0]);
+ $this->db->query(
+ "UPDATE " . $this->db->table_name('identities', true)
+ . " SET `standard` = '1'"
+ . " WHERE `user_id` = ? AND `identity_id` = ?",
+ $this->ID,
+ $iid
+ );
+
+ $this->identities = [];
}
}
@@ -491,10 +506,11 @@ class rcube_user
{
if ($this->ID) {
$this->db->query(
- "UPDATE ".$this->db->table_name('users', true).
- " SET `last_login` = ".$this->db->now().
- " WHERE `user_id` = ?",
- $this->ID);
+ "UPDATE " . $this->db->table_name('users', true)
+ . " SET `last_login` = " . $this->db->now()
+ . " WHERE `user_id` = ?",
+ $this->ID
+ );
}
}
@@ -525,7 +541,8 @@ class rcube_user
. " SET `failed_login` = ?"
. ", `failed_login_counter` = " . ($counter ?: "`failed_login_counter` + 1")
. " WHERE `user_id` = ?",
- $failed_login, $this->ID);
+ $failed_login, $this->ID
+ );
}
}
@@ -581,9 +598,11 @@ class rcube_user
// username not found, try aliases from identities
if (empty($sql_arr) && $config->get('user_aliases') && strpos($user, '@')) {
$sql_result = $dbh->limitquery("SELECT u.*"
- ." FROM " . $dbh->table_name('users', true) . " u"
- ." JOIN " . $dbh->table_name('identities', true) . " i ON (i.`user_id` = u.`user_id`)"
- ." WHERE `email` = ? AND `del` <> 1", 0, 1, $user);
+ . " FROM " . $dbh->table_name('users', true) . " u"
+ . " JOIN " . $dbh->table_name('identities', true) . " i ON (i.`user_id` = u.`user_id`)"
+ . " WHERE `email` = ? AND `del` <> 1",
+ 0, 1, $user
+ );
$sql_arr = $dbh->fetch_assoc($sql_result);
}
@@ -614,15 +633,15 @@ class rcube_user
$user_email = is_array($email_list[0]) ? $email_list[0]['email'] : $email_list[0];
}
- $data = $rcube->plugins->exec_hook('user_create', array(
- 'host' => $host,
- 'user' => $user,
- 'user_name' => $user_name,
- 'user_email' => $user_email,
- 'email_list' => $email_list,
- 'language' => $_SESSION['language'],
- 'preferences' => array(),
- ));
+ $data = $rcube->plugins->exec_hook('user_create', [
+ 'host' => $host,
+ 'user' => $user,
+ 'user_name' => $user_name,
+ 'user_email' => $user_email,
+ 'email_list' => $email_list,
+ 'language' => isset($_SESSION['language']) ? $_SESSION['language'] : null,
+ 'preferences' => [],
+ ]);
// plugin aborted this operation
if ($data['abort']) {
@@ -630,23 +649,24 @@ class rcube_user
}
$insert = $dbh->query(
- "INSERT INTO ".$dbh->table_name('users', true).
- " (`created`, `last_login`, `username`, `mail_host`, `language`, `preferences`)".
- " VALUES (".$dbh->now().", ".$dbh->now().", ?, ?, ?, ?)",
+ "INSERT INTO " . $dbh->table_name('users', true)
+ . " (`created`, `last_login`, `username`, `mail_host`, `language`, `preferences`)"
+ . " VALUES (" . $dbh->now() . ", " . $dbh->now() . ", ?, ?, ?, ?)",
$data['user'],
$data['host'],
$data['language'],
- serialize($data['preferences']));
-
+ serialize($data['preferences'])
+ );
+
if ($dbh->affected_rows($insert) && ($user_id = $dbh->insert_id('users'))) {
// create rcube_user instance to make plugin hooks work
- $user_instance = new rcube_user($user_id, array(
- 'user_id' => $user_id,
- 'username' => $data['user'],
- 'mail_host' => $data['host'],
- 'language' => $data['language'],
- 'preferences' => serialize($data['preferences'])
- ));
+ $user_instance = new rcube_user($user_id, [
+ 'user_id' => $user_id,
+ 'username' => $data['user'],
+ 'mail_host' => $data['host'],
+ 'language' => $data['language'],
+ 'preferences' => serialize($data['preferences']),
+ ]);
$rcube->user = $user_instance;
$mail_domain = $rcube->config->mail_domain($data['host']);
$user_name = $data['user_name'];
@@ -661,7 +681,7 @@ class rcube_user
}
// identities_level check
else if (count($email_list) > 1 && $rcube->config->get('identities_level', 0) > 1) {
- $email_list = array($email_list[0]);
+ $email_list = [$email_list[0]];
}
if (empty($user_name)) {
@@ -671,7 +691,7 @@ class rcube_user
// create new identities records
$standard = 1;
foreach ($email_list as $row) {
- $record = array();
+ $record = [];
if (is_array($row)) {
if (empty($row['email'])) {
@@ -691,21 +711,22 @@ class rcube_user
$record['standard'] = $standard;
$plugin = $rcube->plugins->exec_hook('identity_create',
- array('login' => true, 'record' => $record));
+ ['login' => true, 'record' => $record]);
if (!$plugin['abort'] && $plugin['record']['email']) {
$rcube->user->insert_identity($plugin['record']);
}
+
$standard = 0;
}
}
else {
- rcube::raise_error(array(
- 'code' => 500,
- 'type' => 'php',
- 'line' => __LINE__,
- 'file' => __FILE__,
- 'message' => "Failed to create new user"), true, false);
+ rcube::raise_error([
+ 'code' => 500, 'line' => __LINE__, 'file' => __FILE__,
+ 'message' => "Failed to create new user"
+ ],
+ true, false
+ );
}
return !empty($user_instance) ? $user_instance : null;
@@ -720,9 +741,8 @@ class rcube_user
*/
static function email2user($email)
{
- $rcube = rcube::get_instance();
- $plugin = $rcube->plugins->exec_hook('email2user',
- array('email' => $email, 'user' => null));
+ $rcube = rcube::get_instance();
+ $plugin = $rcube->plugins->exec_hook('email2user', ['email' => $email, 'user' => null]);
return $plugin['user'];
}
@@ -730,18 +750,21 @@ class rcube_user
/**
* Resolve e-mail address from virtuser plugins
*
- * @param string $user User name
- * @param boolean $first If true returns first found entry
- * @param boolean $extended If true returns email as array (email and name for identity)
+ * @param string $user User name
+ * @param bool $first If true returns first found entry
+ * @param bool $extended If true returns email as array (email and name for identity)
*
* @return mixed Resolved e-mail address string or array of strings
*/
- static function user2email($user, $first=true, $extended=false)
+ static function user2email($user, $first = true, $extended = false)
{
- $rcube = rcube::get_instance();
- $plugin = $rcube->plugins->exec_hook('user2email',
- array('email' => null, 'user' => $user,
- 'first' => $first, 'extended' => $extended));
+ $rcube = rcube::get_instance();
+ $plugin = $rcube->plugins->exec_hook('user2email', [
+ 'email' => null,
+ 'user' => $user,
+ 'first' => $first,
+ 'extended' => $extended
+ ]);
return empty($plugin['email']) ? null : $plugin['email'];
}
@@ -755,20 +778,21 @@ class rcube_user
*/
function list_searches($type)
{
- $plugin = $this->rc->plugins->exec_hook('saved_search_list', array('type' => $type));
+ $plugin = $this->rc->plugins->exec_hook('saved_search_list', ['type' => $type]);
if ($plugin['abort']) {
return (array) $plugin['result'];
}
- $result = array();
+ $result = [];
$sql_result = $this->db->query(
"SELECT `search_id` AS id, `name`"
- ." FROM ".$this->db->table_name('searches', true)
- ." WHERE `user_id` = ? AND `type` = ?"
- ." ORDER BY `name`",
- (int) $this->ID, (int) $type);
+ . " FROM " . $this->db->table_name('searches', true)
+ . " WHERE `user_id` = ? AND `type` = ?"
+ . " ORDER BY `name`",
+ (int) $this->ID, (int) $type
+ );
while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
$sql_arr['data'] = unserialize($sql_arr['data']);
@@ -787,27 +811,29 @@ class rcube_user
*/
function get_search($id)
{
- $plugin = $this->rc->plugins->exec_hook('saved_search_get', array('id' => $id));
+ $plugin = $this->rc->plugins->exec_hook('saved_search_get', ['id' => $id]);
if ($plugin['abort']) {
- return $plugin['result'];
+ return (array) $plugin['result'];
}
$sql_result = $this->db->query(
"SELECT `name`, `data`, `type`"
. " FROM ".$this->db->table_name('searches', true)
- . " WHERE `user_id` = ?"
- ." AND `search_id` = ?",
- (int) $this->ID, (int) $id);
+ . " WHERE `user_id` = ? AND `search_id` = ?",
+ (int) $this->ID, (int) $id
+ );
while ($sql_arr = $this->db->fetch_assoc($sql_result)) {
- return array(
+ return [
'id' => $id,
'name' => $sql_arr['name'],
'type' => $sql_arr['type'],
'data' => unserialize($sql_arr['data']),
- );
+ ];
}
+
+ return [];
}
/**
@@ -815,7 +841,7 @@ class rcube_user
*
* @param int $sid Search ID
*
- * @return boolean True if deleted successfully, false if nothing changed
+ * @return bool True if deleted successfully, false if nothing changed
*/
function delete_search($sid)
{
@@ -824,10 +850,10 @@ class rcube_user
}
$this->db->query(
- "DELETE FROM ".$this->db->table_name('searches', true)
- ." WHERE `user_id` = ?"
- ." AND `search_id` = ?",
- (int) $this->ID, $sid);
+ "DELETE FROM " . $this->db->table_name('searches', true)
+ ." WHERE `user_id` = ? AND `search_id` = ?",
+ (int) $this->ID, $sid
+ );
return $this->db->affected_rows() > 0;
}
@@ -854,9 +880,9 @@ class rcube_user
$insert_cols[] = $this->db->quote_identifier('data');
$insert_values[] = serialize($data['data']);
- $sql = "INSERT INTO ".$this->db->table_name('searches', true)
- ." (".implode(', ', $insert_cols).")"
- ." VALUES (".implode(', ', array_pad(array(), count($insert_values), '?')).")";
+ $sql = "INSERT INTO " . $this->db->table_name('searches', true)
+ . " (" . implode(', ', $insert_cols) . ")"
+ . " VALUES (" . implode(', ', array_pad([], count($insert_values), '?')) . ")";
$insert = $this->db->query($sql, $insert_values);
diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php
index e3d3f8b50..3c12b05df 100644
--- a/program/lib/Roundcube/rcube_utils.php
+++ b/program/lib/Roundcube/rcube_utils.php
@@ -161,7 +161,7 @@ class rcube_utils
// Check DNS record(s)
// Note: We can't use ANY (#6581)
- foreach (array('A', 'MX', 'CNAME', 'AAAA') as $type) {
+ foreach (['A', 'MX', 'CNAME', 'AAAA'] as $type) {
if (checkdnsrr($domain_part, $type)) {
return true;
}
@@ -233,7 +233,7 @@ class rcube_utils
// if the replace tables for XML and JS are not yet defined
if ($js_rep_table === false) {
- $js_rep_table = $xml_rep_table = array();
+ $js_rep_table = $xml_rep_table = [];
$xml_rep_table['&'] = '&';
// can be increased to support more charsets
@@ -252,7 +252,7 @@ class rcube_utils
// encode for javascript use
if ($enctype == 'js') {
- return preg_replace(array("/\r?\n/", "/\r/", '/<\\//'), array('\n', '\n', '<\\/'), strtr($str, $js_rep_table));
+ return preg_replace(["/\r?\n/", "/\r/", '/<\\//'], ['\n', '\n', '<\\/'], strtr($str, $js_rep_table));
}
// encode for plaintext
@@ -360,7 +360,7 @@ class rcube_utils
*/
public static function request2param($mode = null, $ignore = 'task|action', $allow_html = false)
{
- $out = array();
+ $out = [];
$src = $mode == self::INPUT_GET ? $_GET : ($mode == self::INPUT_POST ? $_POST : $_REQUEST);
foreach (array_keys($src) as $key) {
@@ -452,7 +452,7 @@ class rcube_utils
}
// allow strict url() values only
else if (stripos($stripped, 'url(') && !preg_match($strict_url_regexp, $line)) {
- $a_styles = array('/* evil! */');
+ $a_styles = ['/* evil! */'];
break;
}
}
@@ -483,7 +483,7 @@ class rcube_utils
}
if ($prefix) {
- $replace = str_replace(array('.', '#'), array(".$prefix", "#$prefix"), $replace);
+ $replace = str_replace(['.', '#'], [".$prefix", "#$prefix"], $replace);
}
if ($container_id) {
@@ -524,14 +524,9 @@ class rcube_utils
$mimetype = strtolower($mimetype);
$filename = strtolower($filename);
- if (strpos($mimetype, '/')) {
- list($primary, $secondary) = explode('/', $mimetype);
- }
- else {
- $primary = $mimetype;
- }
+ list($primary, $secondary) = rcube_utils::explode('/', $mimetype);
- $classes = array($primary ?: 'unknown');
+ $classes = [$primary ?: 'unknown'];
if (!empty($secondary)) {
$classes[] = $secondary;
@@ -571,7 +566,7 @@ class rcube_utils
/**
* Check if we can process not exceeding memory_limit
*
- * @param integer $need Required amount of memory
+ * @param int $need Required amount of memory
*
* @return bool True if memory won't be exceeded, False otherwise
*/
@@ -599,12 +594,12 @@ class rcube_utils
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])
&& strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https'
- && in_array($_SERVER['REMOTE_ADDR'], rcube::get_instance()->config->get('proxy_whitelist', array()))
+ && in_array($_SERVER['REMOTE_ADDR'], (array) rcube::get_instance()->config->get('proxy_whitelist', []))
) {
return true;
}
- if ($port && $_SERVER['SERVER_PORT'] == $port) {
+ if ($port && isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == $port) {
return true;
}
@@ -653,7 +648,7 @@ class rcube_utils
$s = $s[2];
}
- return str_replace(array('%n', '%t', '%d', '%h', '%z', '%s'), array($n, $t, $d, $h, $z, $s), $name);
+ return str_replace(['%n', '%t', '%d', '%h', '%z', '%s'], [$n, $t, $d, $h, $z, $s], $name);
}
/**
@@ -691,8 +686,12 @@ class rcube_utils
}
}
- $rcube->raise_error(array('file' => __FILE__, 'line' => __LINE__,
- 'message' => "Specified host is not trusted. Using 'localhost'."), true, false);
+ $rcube->raise_error([
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => "Specified host is not trusted. Using 'localhost'."
+ ]
+ , true, false
+ );
}
return 'localhost';
@@ -733,7 +732,7 @@ class rcube_utils
{
// Check if any of the headers are set first to improve performance
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']) || !empty($_SERVER['HTTP_X_REAL_IP'])) {
- $proxy_whitelist = rcube::get_instance()->config->get('proxy_whitelist', array());
+ $proxy_whitelist = (array) rcube::get_instance()->config->get('proxy_whitelist', []);
if (in_array($_SERVER['REMOTE_ADDR'], $proxy_whitelist)) {
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
foreach (array_reverse(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])) as $forwarded_ip) {
@@ -792,7 +791,7 @@ class rcube_utils
*/
public static function explode_quoted_string($delimiter, $string)
{
- $result = array();
+ $result = [];
$strlen = strlen($string);
for ($q=$p=$i=0; $i < $strlen; $i++) {
@@ -908,18 +907,20 @@ class rcube_utils
// Clean malformed data
$date = preg_replace(
- array(
+ [
'/\(.*\)/', // remove RFC comments
'/GMT\s*([+-][0-9]+)/', // support non-standard "GMTXXXX" literal
'/[^a-z0-9\x20\x09:\/\.+-]/i', // remove any invalid characters
'/\s*(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*/i', // remove weekday names
- ),
- array(
+ ],
+ [
'',
'\\1',
'',
'',
- ), $date);
+ ],
+ $date
+ );
$date = trim($date);
@@ -1053,8 +1054,8 @@ class rcube_utils
*/
public static function tokenize_string($str, $minlen = 2)
{
- $expr = array('/[\s;,"\'\/+-]+/ui', '/(\d)[-.\s]+(\d)/u');
- $repl = array(' ', '\\1\\2');
+ $expr = ['/[\s;,"\'\/+-]+/ui', '/(\d)[-.\s]+(\d)/u'];
+ $repl = [' ', '\\1\\2'];
if ($minlen > 1) {
$minlen--;
@@ -1096,7 +1097,7 @@ class rcube_utils
preg_match_all('/./', 'aaaaaaaceeeeiiiinoooooouuuuyy', $values);
$mapping = array_combine($keys[0], $values[0]);
- $mapping = array_merge($mapping, array('ß' => 'ss', 'ae' => 'a', 'oe' => 'o', 'ue' => 'u'));
+ $mapping = array_merge($mapping, ['ß' => 'ss', 'ae' => 'a', 'oe' => 'o', 'ue' => 'u']);
}
else if (rcube_charset::convert(rcube_charset::convert($str, 'UTF-8', 'ISO-8859-2'), 'ISO-8859-2', 'UTF-8') == $str) {
// ISO-8859-2
@@ -1104,7 +1105,7 @@ class rcube_utils
preg_match_all('/./', 'aaaaccceeeeiilllnnooorrsssttuuuuzzzy', $values);
$mapping = array_combine($keys[0], $values[0]);
- $mapping = array_merge($mapping, array('ß' => 'ss', 'ae' => 'a', 'oe' => 'o', 'ue' => 'u'));
+ $mapping = array_merge($mapping, ['ß' => 'ss', 'ae' => 'a', 'oe' => 'o', 'ue' => 'u']);
}
foreach ($arr as $i => $part) {
@@ -1156,10 +1157,10 @@ class rcube_utils
*
* @return array Argument values hash
*/
- public static function get_opt($aliases = array())
+ public static function get_opt($aliases = [])
{
- $args = array();
- $bool = array();
+ $args = [];
+ $bool = [];
// find boolean (no value) options
foreach ($aliases as $key => $alias) {
@@ -1190,7 +1191,7 @@ class rcube_utils
$value = $_SERVER['argv'][++$i];
}
- $args[$key] = is_string($value) ? preg_replace(array('/^["\']/', '/["\']$/'), '', $value) : $value;
+ $args[$key] = is_string($value) ? preg_replace(['/^["\']/', '/["\']$/'], '', $value) : $value;
}
else {
$args[] = $arg;
@@ -1254,7 +1255,7 @@ class rcube_utils
{
$str = strtolower($str);
- return !in_array($str, array('false', '0', 'no', 'off', 'nein', ''), true);
+ return !in_array($str, ['false', '0', 'no', 'off', 'nein', ''], true);
}
/**
@@ -1444,7 +1445,7 @@ class rcube_utils
*
* @return bool True on error, False otherwise
*/
- public static function preg_error($error = array(), $terminate = false)
+ public static function preg_error($error = [], $terminate = false)
{
if (($preg_error = preg_last_error()) != PREG_NO_ERROR) {
$errstr = "PCRE Error: $preg_error.";
@@ -1456,7 +1457,7 @@ class rcube_utils
$errstr .= " Consider raising pcre.recursion_limit!";
}
- $error = array_merge(array('code' => 620, 'line' => __LINE__, 'file' => __FILE__), $error);
+ $error = array_merge(['code' => 620, 'line' => __LINE__, 'file' => __FILE__], $error);
if (!empty($error['message'])) {
$error['message'] .= ' ' . $errstr;
diff --git a/program/lib/Roundcube/rcube_vcard.php b/program/lib/Roundcube/rcube_vcard.php
index 2bf3db3f1..f4f8a6c14 100644
--- a/program/lib/Roundcube/rcube_vcard.php
+++ b/program/lib/Roundcube/rcube_vcard.php
@@ -28,11 +28,11 @@
class rcube_vcard
{
private static $values_decoded = false;
- private $raw = array(
- 'FN' => array(),
- 'N' => array(array('','','','','')),
- );
- private static $fieldmap = array(
+ private $raw = [
+ 'FN' => [],
+ 'N' => [['','','','','']],
+ ];
+ private static $fieldmap = [
'phone' => 'TEL',
'birthday' => 'BDAY',
'website' => 'URL',
@@ -49,23 +49,23 @@ class rcube_vcard
'spouse' => 'X-SPOUSE',
'edit' => 'X-AB-EDIT',
'groups' => 'CATEGORIES',
- );
- private $typemap = array(
+ ];
+ private $typemap = [
'IPHONE' => 'mobile',
'CELL' => 'mobile',
'WORK,FAX' => 'workfax',
- );
- private $phonetypemap = array(
+ ];
+ private $phonetypemap = [
'HOME1' => 'HOME',
'BUSINESS1' => 'WORK',
'BUSINESS2' => 'WORK2',
'BUSINESSFAX' => 'WORK,FAX',
'MOBILE' => 'CELL',
- );
- private $addresstypemap = array(
+ ];
+ private $addresstypemap = [
'BUSINESS' => 'WORK',
- );
- private $immap = array(
+ ];
+ private $immap = [
'X-JABBER' => 'jabber',
'X-ICQ' => 'icq',
'X-MSN' => 'msn',
@@ -73,7 +73,7 @@ class rcube_vcard
'X-YAHOO' => 'yahoo',
'X-SKYPE' => 'skype',
'X-SKYPE-USERNAME' => 'skype',
- );
+ ];
public $business = false;
public $displayname;
@@ -82,7 +82,7 @@ class rcube_vcard
public $middlename;
public $nickname;
public $organization;
- public $email = array();
+ public $email = [];
public static $eol = "\r\n";
@@ -96,7 +96,7 @@ class rcube_vcard
* for charset detection is required
* @param array $fieldmap Fields mapping definition
*/
- public function __construct($vcard = null, $charset = RCUBE_CHARSET, $detect = false, $fieldmap = array())
+ public function __construct($vcard = null, $charset = RCUBE_CHARSET, $detect = false, $fieldmap = [])
{
if (!empty($fieldmap)) {
$this->extend_fieldmap($fieldmap);
@@ -170,11 +170,11 @@ class rcube_vcard
*/
public function get_assoc()
{
- $out = array('name' => $this->displayname);
+ $out = ['name' => $this->displayname];
$typemap = $this->typemap;
// copy name fields to output array
- foreach (array('firstname','surname','middlename','nickname','organization') as $col) {
+ foreach (['firstname', 'surname', 'middlename', 'nickname', 'organization'] as $col) {
if (strlen($this->$col)) {
$out[$col] = $this->$col;
}
@@ -203,7 +203,7 @@ class rcube_vcard
if (!empty($raw['type'])) {
$raw['type'] = array_map('strtolower', $raw['type']);
- $combined = implode(',', array_diff($raw['type'], array('internet', 'pref')));
+ $combined = implode(',', array_diff($raw['type'], ['internet', 'pref']));
$combined = strtoupper($combined);
if (!empty($typemap[$combined])) {
@@ -226,7 +226,7 @@ class rcube_vcard
if (!$subtype) {
foreach ($raw as $k => $v) {
if (!is_numeric($k) && $v === true && ($k = strtolower($k))
- && !in_array($k, array('pref','internet','voice','base64'))
+ && !in_array($k, ['pref', 'internet', 'voice', 'base64'])
) {
$k_uc = strtoupper($k);
$subtype = $typemap[$k_uc] ?: $k;
@@ -298,10 +298,10 @@ class rcube_vcard
*
* @param array List of field names to be reset
*/
- public function reset($fields = null)
+ public function reset($fields = [])
{
- if (!$fields) {
- $fields = array('FN', 'N', 'ORG', 'NICKNAME', 'EMAIL', 'ADR', 'BDAY');
+ if (empty($fields)) {
+ $fields = ['FN', 'N', 'ORG', 'NICKNAME', 'EMAIL', 'ADR', 'BDAY'];
$fields = array_merge(array_values(self::$fieldmap), array_keys($this->immap), $fields);
}
@@ -310,14 +310,14 @@ class rcube_vcard
}
if (empty($this->raw['N'])) {
- $this->raw['N'] = array(array('','','','',''));
+ $this->raw['N'] = [['','','','','']];
}
if (empty($this->raw['FN'])) {
- $this->raw['FN'] = array();
+ $this->raw['FN'] = [];
}
- $this->email = array();
+ $this->email = [];
}
/**
@@ -369,15 +369,15 @@ class rcube_vcard
case 'photo':
if (strpos($value, 'http:') === 0) {
// TODO: fetch file from URL and save it locally?
- $this->raw['PHOTO'][0] = array(0 => $value, 'url' => true);
+ $this->raw['PHOTO'][0] = [0 => $value, 'url' => true];
}
else {
- $this->raw['PHOTO'][0] = array(0 => $value, 'base64' => (bool) preg_match('![^a-z0-9/=+-]!i', $value));
+ $this->raw['PHOTO'][0] = [0 => $value, 'base64' => (bool) preg_match('![^a-z0-9/=+-]!i', $value)];
}
break;
case 'email':
- $this->raw['EMAIL'][] = array(0 => $value, 'type' => array_filter(array('INTERNET', $type_uc)));
+ $this->raw['EMAIL'][] = [0 => $value, 'type' => array_filter(['INTERNET', $type_uc])];
$this->email[] = $value;
break;
@@ -386,7 +386,7 @@ class rcube_vcard
$typemap = array_flip($this->immap);
if (!empty($typemap[strtolower($type)])) {
$field = $typemap[strtolower($type)];
- $this->raw[$field][] = array(0 => $value);
+ $this->raw[$field][] = [$value];
}
break;
@@ -394,7 +394,7 @@ class rcube_vcard
case 'anniversary':
if (($val = rcube_utils::anytodatetime($value)) && !empty(self::$fieldmap[$field])) {
$fn = self::$fieldmap[$field];
- $this->raw[$fn][] = array(0 => $val->format('Y-m-d'), 'value' => array('date'));
+ $this->raw[$fn][] = [0 => $val->format('Y-m-d'), 'value' => ['date']];
}
break;
@@ -533,7 +533,7 @@ class rcube_vcard
*/
public static function import($data)
{
- $out = array();
+ $out = [];
// check if charsets are specified (usually vcard version < 3.0 but this is not reliable)
if (preg_match('/charset=/i', substr($data, 0, 2048))) {
@@ -542,7 +542,7 @@ class rcube_vcard
// detect charset and convert to utf-8
else if (($charset = self::detect_encoding($data)) && $charset != RCUBE_CHARSET) {
$data = rcube_charset::convert($data, $charset);
- $data = preg_replace(array('/^[\xFE\xFF]{2}/', '/^\xEF\xBB\xBF/', '/^\x00+/'), '', $data); // also remove BOM
+ $data = preg_replace(['/^[\xFE\xFF]{2}/', '/^\xEF\xBB\xBF/', '/^\x00+/'], '', $data); // also remove BOM
$charset = RCUBE_CHARSET;
}
@@ -588,25 +588,28 @@ class rcube_vcard
// convert Apple X-ABRELATEDNAMES into X-* fields for better compatibility
$vcard = preg_replace_callback(
'/item(\d+)\.(X-ABRELATEDNAMES)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w() -]*)(?:>!\$_)?./s',
- array('rcube_vcard', 'x_abrelatednames_callback'),
+ ['rcube_vcard', 'x_abrelatednames_callback'],
$vcard);
// Cleanup
- $vcard = preg_replace(array(
+ $vcard = preg_replace(
+ [
// convert special types (like Skype) to normal type='skype' classes with this simple regex ;)
'/item(\d+)\.(TEL|EMAIL|URL)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w() -]*)(?:>!\$_)?./si',
'/^item\d*\.X-AB.*$/mi', // remove cruft like item1.X-AB*
'/^item\d*\./mi', // remove item1.ADR instead of ADR
'/\n+/', // remove empty lines
'/^(N:[^;\r\n]*)$/m', // if N doesn't have any semicolons, add some
- ),
- array(
+ ],
+ [
'\2;type=\5\3:\4',
'',
'',
"\n",
'\1;;;;',
- ), $vcard);
+ ],
+ $vcard
+ );
// convert X-WAB-GENDER to X-GENDER
if (preg_match('/X-WAB-GENDER:(\d)/', $vcard, $matches)) {
@@ -665,7 +668,7 @@ class rcube_vcard
*/
public static function rfc2425_fold($val)
{
- return preg_replace_callback('/([^\n]{72,})/', array('rcube_vcard', 'rfc2425_fold_callback'), $val);
+ return preg_replace_callback('/([^\n]{72,})/', ['rcube_vcard', 'rfc2425_fold_callback'], $val);
}
/**
@@ -678,9 +681,9 @@ class rcube_vcard
private static function vcard_decode($vcard)
{
// Perform RFC2425 line unfolding and split lines
- $vcard = preg_replace(array("/\r/", "/\n\s+/"), '', $vcard);
+ $vcard = preg_replace(["/\r/", "/\n\s+/"], '', $vcard);
$lines = explode("\n", $vcard);
- $result = array();
+ $result = [];
for ($i=0; $i < count($lines); $i++) {
if (!($pos = strpos($lines[$i], ':'))) {
@@ -708,7 +711,7 @@ class rcube_vcard
}
if (preg_match_all('/([^\\;]+);?/', $prefix, $regs2)) {
- $entry = array();
+ $entry = [];
$field = strtoupper($regs2[1][0]);
$enc = null;
@@ -829,7 +832,7 @@ class rcube_vcard
foreach ((array)$entries as $entry) {
$attr = '';
if (is_array($entry)) {
- $value = array();
+ $value = [];
foreach ($entry as $attrname => $attrvalues) {
if (is_int($attrname)) {
if (!empty($entry['base64']) || (!empty($entry['encoding']) && $entry['encoding'] == 'B')) {
@@ -883,7 +886,7 @@ class rcube_vcard
public static function vcard_quote($str, $sep = ';')
{
if (is_array($str)) {
- $r = array();
+ $r = [];
foreach ($str as $part) {
$r[] = self::vcard_quote($part, $sep);
@@ -892,7 +895,7 @@ class rcube_vcard
return(implode($sep, $r));
}
- return strtr($str, array("\\" => "\\\\", "\r" => '', "\n" => '\n', $sep => "\\$sep"));
+ return strtr($str, ["\\" => "\\\\", "\r" => '', "\n" => '\n', $sep => "\\$sep"]);
}
/**
@@ -908,11 +911,11 @@ class rcube_vcard
// break string into parts separated by $sep
if (!empty($sep)) {
// Handle properly backslash escaping (#1488896)
- $rep1 = array("\\\\" => "\010", "\\$sep" => "\007");
- $rep2 = array("\007" => "\\$sep", "\010" => "\\\\");
+ $rep1 = ["\\\\" => "\010", "\\$sep" => "\007"];
+ $rep2 = ["\007" => "\\$sep", "\010" => "\\\\"];
if (count($parts = explode($sep, strtr($str, $rep1))) > 1) {
- $result = array();
+ $result = [];
foreach ($parts as $s) {
$result[] = self::vcard_unquote(strtr($s, $rep2));
}
@@ -925,7 +928,7 @@ class rcube_vcard
// some implementations (GMail) use non-standard backslash before colon (#1489085)
// we will handle properly any backslashed character - removing dummy backslahes
- // return strtr($str, array("\r" => '', '\\\\' => '\\', '\n' => "\n", '\N' => "\n", '\,' => ',', '\;' => ';'));
+ // return strtr($str, ["\r" => '', '\\\\' => '\\', '\n' => "\n", '\N' => "\n", '\,' => ',', '\;' => ';']);
$str = str_replace("\r", '', $str);
$pos = 0;
diff --git a/program/lib/Roundcube/rcube_washtml.php b/program/lib/Roundcube/rcube_washtml.php
index 53bf12a2b..b22c9b9a4 100644
--- a/program/lib/Roundcube/rcube_washtml.php
+++ b/program/lib/Roundcube/rcube_washtml.php
@@ -55,7 +55,7 @@ class rcube_washtml
/**
* @var array Allowed HTML elements (default)
*/
- static $html_elements = array('a', 'abbr', 'acronym', 'address', 'area', 'b',
+ static $html_elements = ['a', 'abbr', 'acronym', 'address', 'area', 'b',
'basefont', 'bdo', 'big', 'blockquote', 'br', 'caption', 'center',
'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dir', 'div', 'dl',
'dt', 'em', 'fieldset', 'font', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i',
@@ -87,17 +87,17 @@ class rcube_washtml
'infinity', 'matrix', 'matrixrow', 'ci', 'cn', 'sep', 'apply',
'plus', 'minus', 'eq', 'power', 'times', 'divide', 'csymbol', 'root',
'bvar', 'lowlimit', 'uplimit',
- );
+ ];
/**
* @var array Ignore these HTML tags and their content
*/
- static $ignore_elements = array('script', 'applet', 'embed', 'style');
+ static $ignore_elements = ['script', 'applet', 'embed', 'style'];
/**
* @var array Allowed HTML attributes
*/
- static $html_attribs = array('name', 'class', 'title', 'alt', 'width', 'height',
+ static $html_attribs = ['name', 'class', 'title', 'alt', 'width', 'height',
'align', 'nowrap', 'col', 'row', 'id', 'rowspan', 'colspan', 'cellspacing',
'cellpadding', 'valign', 'bgcolor', 'color', 'border', 'bordercolorlight',
'bordercolordark', 'face', 'marginwidth', 'marginheight', 'axis', 'border',
@@ -143,43 +143,43 @@ class rcube_washtml
'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator',
'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset',
'fontsize', 'fontweight', 'fontstyle', 'fontfamily', 'groupalign', 'edge', 'side',
- );
+ ];
/**
* @var array Elements which could be empty and be returned in short form ( )
*/
- static $void_elements = array('area', 'base', 'br', 'col', 'command', 'embed', 'hr',
+ static $void_elements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr',
'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr',
// MathML
'sep', 'infinity', 'in', 'plus', 'eq', 'power', 'times', 'divide', 'root',
'maligngroup', 'none', 'mprescripts',
- );
+ ];
/**
* @var array Additional allowed attributes of body element
*/
- static $body_attribs = array('alink', 'background', 'bgcolor', 'link', 'text', 'vlink');
+ static $body_attribs = ['alink', 'background', 'bgcolor', 'link', 'text', 'vlink'];
/** @var bool State indicating existence of linked objects in HTML */
public $extlinks = false;
/** @var array Current settings */
- private $config = array();
+ private $config = [];
/** @var array Registered callback functions for tags */
- private $handlers = array();
+ private $handlers = [];
/** @var array Allowed HTML elements */
- private $_html_elements = array();
+ private $_html_elements = [];
/** @var array Ignore these HTML tags but process their content */
- private $_ignore_elements = array();
+ private $_ignore_elements = [];
/** @var array Elements which could be empty and be returned in short form ( ) */
- private $_void_elements = array();
+ private $_void_elements = [];
/** @var array Allowed HTML attributes */
- private $_html_attribs = array();
+ private $_html_attribs = [];
/** @var string A prefix to be added to id/class/for attribute values */
private $_css_prefix;
@@ -210,7 +210,7 @@ class rcube_washtml
* html_attribs: Additional allowed HTML attributes
* void_elements: Elements which could be empty and be returned in short form ( )
*/
- public function __construct($p = array())
+ public function __construct($p = [])
{
$p['html_elements'] = isset($p['html_elements']) ? (array) $p['html_elements'] : [];
$p['html_attribs'] = isset($p['html_attribs']) ? (array) $p['html_attribs'] : [];
@@ -252,7 +252,7 @@ class rcube_washtml
*/
private function wash_style($style)
{
- $result = array();
+ $result = [];
// Remove unwanted white-space characters so regular expressions below work better
$style = preg_replace('/[\n\r\s\t]+/', ' ', $style);
@@ -311,8 +311,8 @@ class rcube_washtml
private function wash_attribs($node)
{
$result = '';
- $washed = array();
- $additional_attribs = array();
+ $washed = [];
+ $additional_attribs = [];
if ($node->nodeName == 'body') {
$additional_attribs = self::$body_attribs;
@@ -362,7 +362,7 @@ class rcube_washtml
$out = $value;
}
}
- else if ($this->_css_prefix !== null && in_array($key, array('id', 'class', 'for'))) {
+ else if ($this->_css_prefix !== null && in_array($key, ['id', 'class', 'for'])) {
$out = preg_replace('/(\S+)/', $this->_css_prefix . '\1', $value);
}
else if ($key) {
@@ -409,7 +409,7 @@ class rcube_washtml
}
// allow url(#id) used in SVG
- if ($uri[0] == '#') {
+ if (isset($uri[0]) && $uri[0] == '#') {
if ($this->_css_prefix !== null) {
$uri = '#' . $this->_css_prefix . substr($uri, 1);
}
@@ -520,8 +520,8 @@ class rcube_washtml
*/
private function is_funciri_attribute($tag, $attr)
{
- return in_array($attr, array('fill', 'filter', 'stroke', 'marker-start',
- 'marker-end', 'marker-mid', 'clip-path', 'mask', 'cursor'));
+ return in_array($attr, ['fill', 'filter', 'stroke', 'marker-start',
+ 'marker-end', 'marker-mid', 'clip-path', 'mask', 'cursor']);
}
/**
@@ -570,10 +570,12 @@ class rcube_washtml
// log error message once
if (empty($this->max_nesting_level_error)) {
$this->max_nesting_level_error = true;
- rcube::raise_error(array('code' => 500, 'type' => 'php',
- 'line' => __LINE__, 'file' => __FILE__,
- 'message' => "Maximum nesting level exceeded (xdebug.max_nesting_level={$this->max_nesting_level})"),
- true, false);
+ rcube::raise_error([
+ 'code' => 500, 'line' => __LINE__, 'file' => __FILE__,
+ 'message' => "Maximum nesting level exceeded (xdebug.max_nesting_level={$this->max_nesting_level})"
+ ],
+ true, false
+ );
}
return '';
@@ -596,7 +598,7 @@ class rcube_washtml
$node->setAttribute('href', (string) $uri);
}
- else if (in_array($tagName, array('animate', 'animatecolor', 'set', 'animatetransform'))
+ else if (in_array($tagName, ['animate', 'animatecolor', 'set', 'animatetransform'])
&& self::attribute_value($node, 'attributename', 'href')
) {
// Insecure svg tags
@@ -738,7 +740,7 @@ class rcube_washtml
$html = trim($html);
// special replacements (not properly handled by washtml class)
- $html_search = array(
+ $html_search = [
// space(s) between
'/(<\/nobr>)(\s+)()/i',
// PHP bug #32547 workaround: remove title tag
@@ -752,42 +754,42 @@ class rcube_washtml
// washtml/DOMDocument cannot handle xml namespaces
// HTML5 parser cannot handler ]*>/i',
- );
+ ];
- $html_replace = array(
+ $html_replace = [
'\\1'.' '.'\\3',
'',
'',
'',
'',
'',
- );
+ ];
$html = preg_replace($html_search, $html_replace, $html);
- $err = array('line' => __LINE__, 'file' => __FILE__, 'message' => "Could not clean up HTML!");
+ $err = ['line' => __LINE__, 'file' => __FILE__, 'message' => "Could not clean up HTML!"];
if ($html === null && rcube_utils::preg_error($err)) {
return '';
}
// Replace all of those weird MS Word quotes and other high characters
- $badwordchars = array(
+ $badwordchars = [
"\xe2\x80\x98", // left single quote
"\xe2\x80\x99", // right single quote
"\xe2\x80\x9c", // left double quote
"\xe2\x80\x9d", // right double quote
"\xe2\x80\x94", // em dash
"\xe2\x80\xa6" // elipses
- );
+ ];
- $fixedwordchars = array(
+ $fixedwordchars = [
"'",
"'",
'"',
'"',
'—',
'...'
- );
+ ];
$html = str_replace($badwordchars, $fixedwordchars, $html);
@@ -795,7 +797,7 @@ class rcube_washtml
// we should probably do not modify content inside comments at all.
// fix (unknown/malformed) HTML tags before "wash"
- $html = preg_replace_callback('/(<(?!\!)[\/]*)([^\s>]+)([^>]*)/', array($this, 'html_tag_callback'), $html);
+ $html = preg_replace_callback('/(<(?!\!)[\/]*)([^\s>]+)([^>]*)/', [$this, 'html_tag_callback'], $html);
// Remove invalid HTML comments (#1487759)
// Note: We don't want to remove valid comments, conditional comments
@@ -827,10 +829,11 @@ class rcube_washtml
}
$tagname = $matches[2];
- $tagname = preg_replace(array(
- '/:.*$/', // Microsoft's Smart Tags
- '/[^a-z0-9_\[\]\!?-]/i', // forbidden characters
- ), '', $tagname);
+ $tagname = preg_replace([
+ '/:.*$/', // Microsoft's Smart Tags
+ '/[^a-z0-9_\[\]\!?-]/i', // forbidden characters
+ ], '', $tagname
+ );
// fix invalid closing tags - remove any attributes (#1489446)
if ($matches[1] == '') {
@@ -866,13 +869,13 @@ class rcube_washtml
public static function fix_broken_lists(&$html)
{
// do two rounds, one for , one for
- foreach (array('ol', 'ul') as $tag) {
+ foreach (['ol', 'ul'] as $tag) {
$pos = 0;
while (($pos = stripos($html, '<' . $tag, $pos)) !== false) {
$pos++;
// make sure this is an ol/ul tag
- if (!in_array($html[$pos+2], array(' ', '>'))) {
+ if (!in_array($html[$pos+2], [' ', '>'])) {
continue;
}
@@ -889,13 +892,13 @@ class rcube_washtml
$p += 4;
}
// li close tag
- else if ($tt == ''))) {
+ else if ($tt == ''])) {
$li_pos = $p;
$in_li = false;
$p += 4;
}
// ul/ol closing tag
- else if ($tt == '' . $tag && in_array($html[$p+4], array(' ', '>'))) {
+ else if ($tt == '' . $tag && in_array($html[$p+4], [' ', '>'])) {
break;
}
// nested ol/ul element out of li
@@ -996,7 +999,7 @@ class rcube_washtml
$style = trim($style);
$strlen = strlen($style);
- $result = array();
+ $result = [];
$q = false;
// explode value
diff --git a/tests/Actions/Settings/PrefsSave.php b/tests/Actions/Settings/PrefsSave.php
index c9715c7e1..1c711737e 100644
--- a/tests/Actions/Settings/PrefsSave.php
+++ b/tests/Actions/Settings/PrefsSave.php
@@ -35,6 +35,9 @@ class Actions_Settings_PrefsSave extends ActionTestCase
$action = new rcmail_action_settings_prefs_save;
$_POST = ['_test' => 'test'];
+
+ rcmail::get_instance()->config->set('test', null);
+
$this->assertSame(null, $action->prefs_input('unset', '/test/'));
$this->assertSame('test', $action->prefs_input('test', '/^test/'));
$this->assertSame(null, $action->prefs_input('test', '/^a/'));
diff --git a/tests/Browser/bootstrap.php b/tests/Browser/bootstrap.php
index b1ce4c9ef..9baf8cd91 100644
--- a/tests/Browser/bootstrap.php
+++ b/tests/Browser/bootstrap.php
@@ -133,7 +133,7 @@ class bootstrap
$a_host = parse_url($imap_host);
if (!empty($a_host['host'])) {
$imap_host = $a_host['host'];
- $imap_ssl = isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'));
+ $imap_ssl = isset($a_host['scheme']) && in_array($a_host['scheme'], ['ssl','imaps','tls']);
$imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : 143);
}
else {
diff --git a/tests/Framework/CacheDB.php b/tests/Framework/CacheDB.php
index b1283529d..2e274a40f 100644
--- a/tests/Framework/CacheDB.php
+++ b/tests/Framework/CacheDB.php
@@ -17,7 +17,7 @@ class Framework_CacheDB extends PHPUnit\Framework\TestCase
$db->query('DELETE FROM cache');
$cache = new rcube_cache_db(1, 'test', 60);
-rcube::write_log('sql', '>>>>>>>>>>>>>>>>>>>>>>>>');
+
// Set and get cache record
$data = ['data'];
diff --git a/tests/Framework/Output.php b/tests/Framework/Output.php
new file mode 100644
index 000000000..09dd24d98
--- /dev/null
+++ b/tests/Framework/Output.php
@@ -0,0 +1,56 @@
+assertSame('', $out);
+
+ $_POST['_test'] = 'testv';
+ $out = rcube_output::get_edit_field('test', 'value');
+
+ $this->assertSame('', $out);
+
+ $out = rcube_output::get_edit_field('test', 'value', ['class' => 'a'], 'checkbox');
+
+ $this->assertSame('', $out);
+
+ $out = rcube_output::get_edit_field('test', 'value', ['class' => 'a'], 'textarea');
+
+ $this->assertSame('', $out);
+
+ $out = rcube_output::get_edit_field('test', 'value', ['class' => 'a'], 'select');
+
+ $this->assertSame('', $out);
+
+ $_POST['_test'] = 'tt';
+ $attr = ['options' => ['tt' => 'oo']];
+ $out = rcube_output::get_edit_field('test', 'value', $attr, 'select');
+
+ $this->assertSame('',
+ $out
+ );
+ }
+
+ /**
+ * Test json_serialize()
+ */
+ function test_json_serialize()
+ {
+ $this->assertSame('""', rcube_output::json_serialize(''));
+ $this->assertSame('[]', rcube_output::json_serialize([]));
+ $this->assertSame('10', rcube_output::json_serialize(10));
+ $this->assertSame('{"test":"test"}', rcube_output::json_serialize(['test' => 'test']));
+ }
+}
diff --git a/tests/Framework/StringReplacer.php b/tests/Framework/StringReplacer.php
index 07649bd01..2a9550634 100644
--- a/tests/Framework/StringReplacer.php
+++ b/tests/Framework/StringReplacer.php
@@ -7,7 +7,6 @@
*/
class Framework_StringReplacer extends PHPUnit\Framework\TestCase
{
-
/**
* Class constructor
*/
@@ -23,33 +22,33 @@ class Framework_StringReplacer extends PHPUnit\Framework\TestCase
*/
function data_replace()
{
- return array(
- array('http://domain.tld/path*path2', 'http://domain.tld/path*path2'),
- array("Click this link:\nhttps://mail.xn--brderli-o2a.ch/rc/ EOF", "Click this link:\nhttps://mail.xn--brderli-o2a.ch/rc/ EOF"),
- array('Start http://localhost/?foo End', 'Start http://localhost/?foo End'),
- array('http://localhost/?foo=bar. Period', 'http://localhost/?foo=bar. Period'),
- array('www.domain.tld', 'www.domain.tld'),
- array('WWW.DOMAIN.TLD', 'WWW.DOMAIN.TLD'),
- array('[http://link.com]', '[http://link.com]'),
- array('http://link.com?a[]=1', 'http://link.com?a[]=1'),
- array('http://link.com?a[]', 'http://link.com?a[]'),
- array('(http://link.com)', '(http://link.com)'),
- array('http://link.com?a(b)c', 'http://link.com?a(b)c'),
- array('http://link.com?(link)', 'http://link.com?(link)'),
- array('https://github.com/a/b/compare/3a0f82...1f4b2a after', 'https://github.com/a/b/compare/3a0f82...1f4b2a after'),
- array('http://', 'http://'),
- array('http://', 'http://'),
- array('test test@www.test test', 'test test@www.test test'),
- array("test 'test@www.test' test", "test 'test@www.test' test"),
- array('test "test@www.test" test', 'test "test@www.test" test'),
- array('a 1@1.com www.domain.tld', 'a 1@1.com www.domain.tld'),
- array(' www.domain.tld ', ' www.domain.tld '),
- array(' www.domain.tld/#!download|856p1|2 ', ' www.domain.tld/#!download|856p1|2 '),
+ return [
+ ['http://domain.tld/path*path2', 'http://domain.tld/path*path2'],
+ ["Click this link:\nhttps://mail.xn--brderli-o2a.ch/rc/ EOF", "Click this link:\nhttps://mail.xn--brderli-o2a.ch/rc/ EOF"],
+ ['Start http://localhost/?foo End', 'Start http://localhost/?foo End'],
+ ['http://localhost/?foo=bar. Period', 'http://localhost/?foo=bar. Period'],
+ ['www.domain.tld', 'www.domain.tld'],
+ ['WWW.DOMAIN.TLD', 'WWW.DOMAIN.TLD'],
+ ['[http://link.com]', '[http://link.com]'],
+ ['http://link.com?a[]=1', 'http://link.com?a[]=1'],
+ ['http://link.com?a[]', 'http://link.com?a[]'],
+ ['(http://link.com)', '(http://link.com)'],
+ ['http://link.com?a(b)c', 'http://link.com?a(b)c'],
+ ['http://link.com?(link)', 'http://link.com?(link)'],
+ ['https://github.com/a/b/compare/3a0f82...1f4b2a after', 'https://github.com/a/b/compare/3a0f82...1f4b2a after'],
+ ['http://', 'http://'],
+ ['http://', 'http://'],
+ ['test test@www.test test', 'test test@www.test test'],
+ ["test 'test@www.test' test", "test 'test@www.test' test"],
+ ['test "test@www.test" test', 'test "test@www.test" test'],
+ ['a 1@1.com www.domain.tld', 'a 1@1.com www.domain.tld'],
+ [' www.domain.tld ', ' www.domain.tld '],
+ [' www.domain.tld/#!download|856p1|2 ', ' www.domain.tld/#!download|856p1|2 '],
// #1489898: allow some unicode characters
- array('https://www.google.com/maps/place/New+York,+État+de+New+York/@40.7056308,-73.9780035,11z/data=!3m1!4b1!4m2!3m1!1s0x89c24fa5d33f083b:0xc80b8f06e177fe62',
+ ['https://www.google.com/maps/place/New+York,+État+de+New+York/@40.7056308,-73.9780035,11z/data=!3m1!4b1!4m2!3m1!1s0x89c24fa5d33f083b:0xc80b8f06e177fe62',
'https://www.google.com/maps/place/New+York,+État+de+New+York/@40.7056308,-73.9780035,11z/data=!3m1!4b1!4m2!3m1!1s0x89c24fa5d33f083b:0xc80b8f06e177fe62'
- ),
- );
+ ],
+ ];
}
/**
diff --git a/tests/Framework/Text2Html.php b/tests/Framework/Text2Html.php
index 52d448090..055ce1bc8 100644
--- a/tests/Framework/Text2Html.php
+++ b/tests/Framework/Text2Html.php
@@ -7,13 +7,12 @@
*/
class Framework_Text2Html extends PHPUnit\Framework\TestCase
{
-
/**
* Data for test_text2html()
*/
function data_text2html()
{
- $options = array(
+ $options = [
'begin' => '',
'end' => '',
'break' => '
',
@@ -24,85 +23,85 @@ class Framework_Text2Html extends PHPUnit\Framework\TestCase
'space' => '_', // replace UTF-8 non-breaking space for simpler testing
'nobr_start' => '>',
'nobr_end' => '<',
- );
+ ];
- $data[] = array(" aaaa", ">_aaaa<", $options);
- $data[] = array("aa>aa", ">aa>aa<", $options);
- $data[] = array("aaaa aaaa", ">aaaa_aaaa<", $options);
- $data[] = array("aaaa aaaa", ">aaaa__aaaa<", $options);
- $data[] = array("aaaa aaaa", ">aaaa___aaaa<", $options);
- $data[] = array("aaaa\taaaa", ">aaaa____aaaa<", $options);
- $data[] = array("aaaa\naaaa", "aaaa
aaaa", $options);
- $data[] = array("aaaa\n aaaa", "aaaa
>_aaaa<", $options);
- $data[] = array("aaaa\n aaaa", "aaaa
>__aaaa<", $options);
- $data[] = array("aaaa\n aaaa", "aaaa
>___aaaa<", $options);
- $data[] = array("\n", "
", $options);
- $data[] = array("\taaaa", ">____aaaa<", $options);
- $data[] = array("\naaaa", "
aaaa", $options);
- $data[] = array("\n aaaa", "
>_aaaa<", $options);
- $data[] = array("\n aaaa", "
>__aaaa<", $options);
- $data[] = array("\n aaaa", "
>___aaaa<", $options);
- $data[] = array("aaaa\n\nbbbb", "aaaa
bbbb", $options);
- $data[] = array(">aaaa \n>aaaa", ">aaaa_<
aaaa
", $options);
- $data[] = array(">aaaa\n>aaaa", "aaaa
aaaa
", $options);
- $data[] = array(">aaaa \n>bbbb\ncccc dddd", ">aaaa_<
bbbb
>cccc_dddd<", $options);
- $data[] = array("aaaa-bbbb/cccc", ">aaaa-bbbb/cccc<", $options);
- $data[] = array("aaaa-bbbb\r\tcccc", ">aaaa-bbbb____cccc<", $options);
+ $data[] = [" aaaa", ">_aaaa<", $options];
+ $data[] = ["aa>aa", ">aa>aa<", $options];
+ $data[] = ["aaaa aaaa", ">aaaa_aaaa<", $options];
+ $data[] = ["aaaa aaaa", ">aaaa__aaaa<", $options];
+ $data[] = ["aaaa aaaa", ">aaaa___aaaa<", $options];
+ $data[] = ["aaaa\taaaa", ">aaaa____aaaa<", $options];
+ $data[] = ["aaaa\naaaa", "aaaa
aaaa", $options];
+ $data[] = ["aaaa\n aaaa", "aaaa
>_aaaa<", $options];
+ $data[] = ["aaaa\n aaaa", "aaaa
>__aaaa<", $options];
+ $data[] = ["aaaa\n aaaa", "aaaa
>___aaaa<", $options];
+ $data[] = ["\n", "
", $options];
+ $data[] = ["\taaaa", ">____aaaa<", $options];
+ $data[] = ["\naaaa", "
aaaa", $options];
+ $data[] = ["\n aaaa", "
>_aaaa<", $options];
+ $data[] = ["\n aaaa", "
>__aaaa<", $options];
+ $data[] = ["\n aaaa", "
>___aaaa<", $options];
+ $data[] = ["aaaa\n\nbbbb", "aaaa
bbbb", $options];
+ $data[] = [">aaaa \n>aaaa", ">aaaa_<
aaaa
", $options];
+ $data[] = [">aaaa\n>aaaa", "aaaa
aaaa
", $options];
+ $data[] = [">aaaa \n>bbbb\ncccc dddd", ">aaaa_<
bbbb
>cccc_dddd<", $options];
+ $data[] = ["aaaa-bbbb/cccc", ">aaaa-bbbb/cccc<", $options];
+ $data[] = ["aaaa-bbbb\r\tcccc", ">aaaa-bbbb____cccc<", $options];
$options['flowed'] = true;
- $data[] = array(" aaaa", "aaaa", $options);
- $data[] = array("aaaa aaaa", ">aaaa_aaaa<", $options);
- $data[] = array("aaaa aaaa", ">aaaa__aaaa<", $options);
- $data[] = array("aaaa aaaa", ">aaaa___aaaa<", $options);
- $data[] = array("aaaa\taaaa", ">aaaa____aaaa<", $options);
- $data[] = array("aaaa\naaaa", "aaaa
aaaa", $options);
- $data[] = array("aaaa\n aaaa", "aaaa
aaaa", $options);
- $data[] = array("aaaa\n aaaa", "aaaa
>_aaaa<", $options);
- $data[] = array("aaaa\n aaaa", "aaaa
>__aaaa<", $options);
- $data[] = array("\taaaa", ">____aaaa<", $options);
- $data[] = array("\naaaa", "
aaaa", $options);
- $data[] = array("\n aaaa", "
aaaa", $options);
- $data[] = array("\n aaaa", "
>_aaaa<", $options);
- $data[] = array("\n aaaa", "
>__aaaa<", $options);
- $data[] = array("aaaa\n\nbbbb", "aaaa
bbbb", $options);
- $data[] = array(">aaaa \n>aaaa", "aaaa aaaa
", $options);
- $data[] = array(">aaaa\n>aaaa", "aaaa
aaaa
", $options);
- $data[] = array(">aaaa \n>bbbb\ncccc dddd", "aaaa bbbb
>cccc_dddd<", $options);
- $data[] = array("\x02\x03", ">\x02\x03<", $options);
+ $data[] = [" aaaa", "aaaa", $options];
+ $data[] = ["aaaa aaaa", ">aaaa_aaaa<", $options];
+ $data[] = ["aaaa aaaa", ">aaaa__aaaa<", $options];
+ $data[] = ["aaaa aaaa", ">aaaa___aaaa<", $options];
+ $data[] = ["aaaa\taaaa", ">aaaa____aaaa<", $options];
+ $data[] = ["aaaa\naaaa", "aaaa
aaaa", $options];
+ $data[] = ["aaaa\n aaaa", "aaaa
aaaa", $options];
+ $data[] = ["aaaa\n aaaa", "aaaa
>_aaaa<", $options];
+ $data[] = ["aaaa\n aaaa", "aaaa
>__aaaa<", $options];
+ $data[] = ["\taaaa", ">____aaaa<", $options];
+ $data[] = ["\naaaa", "
aaaa", $options];
+ $data[] = ["\n aaaa", "
aaaa", $options];
+ $data[] = ["\n aaaa", "
>_aaaa<", $options];
+ $data[] = ["\n aaaa", "
>__aaaa<", $options];
+ $data[] = ["aaaa\n\nbbbb", "aaaa
bbbb", $options];
+ $data[] = [">aaaa \n>aaaa", "aaaa aaaa
", $options];
+ $data[] = [">aaaa\n>aaaa", "aaaa
aaaa
", $options];
+ $data[] = [">aaaa \n>bbbb\ncccc dddd", "aaaa bbbb
>cccc_dddd<", $options];
+ $data[] = ["\x02\x03", ">\x02\x03<", $options];
$options['flowed'] = true;
$options['delsp'] = true;
- $data[] = array(" aaaa", "aaaa", $options);
- $data[] = array("aaaa aaaa", ">aaaa_aaaa<", $options);
- $data[] = array("aaaa aaaa", ">aaaa__aaaa<", $options);
- $data[] = array("aaaa aaaa", ">aaaa___aaaa<", $options);
- $data[] = array("aaaa\taaaa", ">aaaa____aaaa<", $options);
- $data[] = array("aaaa\naaaa", "aaaa
aaaa", $options);
- $data[] = array("aaaa\n aaaa", "aaaa
aaaa", $options);
- $data[] = array("aaaa\n aaaa", "aaaa
>_aaaa<", $options);
- $data[] = array("aaaa\n aaaa", "aaaa
>__aaaa<", $options);
- $data[] = array("\taaaa", ">____aaaa<", $options);
- $data[] = array("\naaaa", "
aaaa", $options);
- $data[] = array("\n aaaa", "
aaaa", $options);
- $data[] = array("\n aaaa", "
>_aaaa<", $options);
- $data[] = array("\n aaaa", "
>__aaaa<", $options);
- $data[] = array("aaaa\n\nbbbb", "aaaa
bbbb", $options);
- $data[] = array(">aaaa \n>aaaa", "aaaaaaaa
", $options);
- $data[] = array(">aaaa\n>aaaa", "aaaa
aaaa
", $options);
- $data[] = array(">aaaa \n>bbbb\ncccc dddd", "aaaabbbb
>cccc_dddd<", $options);
+ $data[] = [" aaaa", "aaaa", $options];
+ $data[] = ["aaaa aaaa", ">aaaa_aaaa<", $options];
+ $data[] = ["aaaa aaaa", ">aaaa__aaaa<", $options];
+ $data[] = ["aaaa aaaa", ">aaaa___aaaa<", $options];
+ $data[] = ["aaaa\taaaa", ">aaaa____aaaa<", $options];
+ $data[] = ["aaaa\naaaa", "aaaa
aaaa", $options];
+ $data[] = ["aaaa\n aaaa", "aaaa
aaaa", $options];
+ $data[] = ["aaaa\n aaaa", "aaaa
>_aaaa<", $options];
+ $data[] = ["aaaa\n aaaa", "aaaa
>__aaaa<", $options];
+ $data[] = ["\taaaa", ">____aaaa<", $options];
+ $data[] = ["\naaaa", "
aaaa", $options];
+ $data[] = ["\n aaaa", "
aaaa", $options];
+ $data[] = ["\n aaaa", "
>_aaaa<", $options];
+ $data[] = ["\n aaaa", "
>__aaaa<", $options];
+ $data[] = ["aaaa\n\nbbbb", "aaaa
bbbb", $options];
+ $data[] = [">aaaa \n>aaaa", "aaaaaaaa
", $options];
+ $data[] = [">aaaa\n>aaaa", "aaaa
aaaa
", $options];
+ $data[] = [">aaaa \n>bbbb\ncccc dddd", "aaaabbbb
>cccc_dddd<", $options];
$options['flowed'] = false;
$options['delsp'] = false;
$options['wrap'] = true;
- $data[] = array(">>aaaa bbbb\n>>\n>>>\n>cccc\n\ndddd eeee",
- "aaaa bbbb
cccc
dddd eeee", $options);
- $data[] = array("\n>>aaaa\n\ndddd",
- "
aaaa
dddd", $options);
- $data[] = array("aaaa\n>bbbb\n>cccc\n\ndddd\n>>test",
- "aaaabbbb
cccc
ddddtest
", $options);
+ $data[] = [">>aaaa bbbb\n>>\n>>>\n>cccc\n\ndddd eeee",
+ "aaaa bbbb
cccc
dddd eeee", $options];
+ $data[] = ["\n>>aaaa\n\ndddd",
+ "
aaaa
dddd", $options];
+ $data[] = ["aaaa\n>bbbb\n>cccc\n\ndddd\n>>test",
+ "aaaabbbb
cccc
ddddtest
", $options];
return $data;
}
diff --git a/tests/Framework/TnefDecoder.php b/tests/Framework/TnefDecoder.php
index c367ba615..a935ddd3a 100644
--- a/tests/Framework/TnefDecoder.php
+++ b/tests/Framework/TnefDecoder.php
@@ -7,7 +7,6 @@
*/
class Framework_TnefDecoder extends PHPUnit\Framework\TestCase
{
-
/**
* Test TNEF decoding
*/
@@ -25,4 +24,28 @@ class Framework_TnefDecoder extends PHPUnit\Framework\TestCase
$this->assertSame(244, $result['attachments'][0]['size']);
$this->assertRegExp('/Mark Simpson/', $result['attachments'][0]['stream']);
}
+
+ /**
+ * Test rtf2text()
+ */
+ function test_rtf2text()
+ {
+ $body = file_get_contents(TESTS_DIR . 'src/sample.rtf');
+ $text = rcube_tnef_decoder::rtf2text($body);
+
+ $this->assertRegExp('/^[a-zA-Z1-6!&<,> \n\.]+$/', $text);
+ $this->assertTrue(strpos($text, 'Alex Skolnick') !== false);
+ $this->assertTrue(strpos($text, 'Heading 1') !== false);
+ $this->assertTrue(strpos($text, 'Heading 2') !== false);
+ $this->assertTrue(strpos($text, 'Heading 3') !== false);
+ $this->assertTrue(strpos($text, 'Heading 4') !== false);
+ $this->assertTrue(strpos($text, 'Heading 5') !== false);
+ $this->assertTrue(strpos($text, 'Heading 6') !== false);
+ $this->assertTrue(strpos($text, 'This is the first normal paragraph!') !== false);
+ $this->assertTrue(strpos($text, 'This is a chunk of normal text.') !== false);
+ $this->assertTrue(strpos($text, 'This is a chunk of normal text with specials, &, <, and >.') !== false);
+ $this->assertTrue(strpos($text, 'This is a second paragraph.') !== false);
+ $this->assertTrue(strpos($text, 'This is text with embedded bold, italic, and underline styles.') !== false);
+ $this->assertTrue(strpos($text, 'Here is the anchor style. And here is the Image style.') !== false);
+ }
}
diff --git a/tests/Framework/User.php b/tests/Framework/User.php
index 9065209ef..f2b50618c 100644
--- a/tests/Framework/User.php
+++ b/tests/Framework/User.php
@@ -5,16 +5,199 @@
*
* @package Tests
*/
-class Framework_User extends PHPUnit\Framework\TestCase
+class Framework_User extends ActionTestCase
{
+ /**
+ * Test class constructor
+ */
+ function test_constructor()
+ {
+ self::initDB('init');
+
+ $user = new rcube_user(1);
+
+ $this->assertSame(1, $user->ID);
+ $this->assertSame(null, $user->language);
+ }
/**
- * Class constructor
+ * Test get_username()
*/
- function test_class()
+ function test_get_username()
{
- $user = new rcube_user;
+ self::initDB('init');
- $this->assertInstanceOf('rcube_user', $user, "Class constructor");
+ $user = new rcube_user(1);
+
+ $this->assertSame('test@example.com', $user->get_username());
+ $this->assertSame('test', $user->get_username('local'));
+ $this->assertSame('example.com', $user->get_username('domain'));
+ }
+
+ /**
+ * Test save_prefs() and get_prefs() and get_hash()
+ */
+ function test_save_prefs()
+ {
+ self::initDB('init');
+
+ $user = new rcube_user(1);
+
+ $this->assertSame([], $user->get_prefs());
+
+ $user->save_prefs(['test' => 'test'], true);
+
+ $user = new rcube_user(1);
+
+ $this->assertSame(['test' => 'test'], $user->get_prefs());
+
+ $hash = $user->get_hash();
+
+ $this->assertRegExp('/^[a-zA-Z0-9]{16}$/', $hash);
+
+ $user = new rcube_user(1);
+
+ $prefs = $user->get_prefs();
+
+ $this->assertSame('test', $prefs['test']);
+ $this->assertSame($hash, $prefs['client_hash']);
+ $this->assertSame($hash, $user->get_hash());
+ }
+
+ /**
+ * Test identities related methods
+ */
+ function test_list_emails_and_identities()
+ {
+ self::initDB('init');
+ self::initDB('identities');
+
+ $user = new rcube_user(1);
+
+ $all = $user->list_emails();
+
+ $this->assertCount(2, $all);
+ $this->assertSame('test@example.com', $all[0]['email']);
+ $this->assertSame('test@example.org', $all[1]['email']);
+
+ $ident = $user->list_emails(true);
+
+ $this->assertSame('test@example.com', $ident['email']);
+
+ $ident = $user->get_identity();
+
+ $this->assertSame('test@example.com', $ident['email']);
+
+ $idents = $user->list_identities('', true);
+
+ $this->assertCount(2, $idents);
+ $this->assertSame('test@example.com', $idents[0]['email_ascii']);
+ $this->assertSame('test ', $idents[0]['ident']);
+ $this->assertSame('test@example.org', $idents[1]['email_ascii']);
+ $this->assertSame('test ', $idents[1]['ident']);
+
+ $default = $idents[0]['identity_id'];
+
+ $res = $user->update_identity($idents[1]['identity_id'], ['name' => 'test-new']);
+
+ $this->assertTrue($res);
+
+ $ident = $user->get_identity($idents[1]['identity_id']);
+
+ $this->assertSame('test-new', $ident['name']);
+
+ $id = $user->insert_identity([
+ 'name' => 'name',
+ 'email' => 'add@ident.com',
+ ]);
+
+ $this->assertTrue(is_numeric($id));
+
+ $ident = $user->get_identity($id);
+
+ $this->assertSame('name', $ident['name']);
+ $this->assertSame('add@ident.com', $ident['email']);
+
+ $idents = $user->list_identities();
+
+ $this->assertCount(3, $idents);
+
+ $ident = $user->set_default($id);
+
+ $idents = $user->list_identities();
+
+ $this->assertCount(3, $idents);
+ $this->assertSame('add@ident.com', $idents[0]['email']);
+ $this->assertEquals(1, $idents[0]['standard']);
+ $this->assertSame('test@example.com', $idents[1]['email']);
+ $this->assertEquals(0, $idents[1]['standard']);
+ $this->assertSame('test@example.org', $idents[2]['email']);
+ $this->assertEquals(0, $idents[2]['standard']);
+
+ $ident = $user->delete_identity($default);
+
+ $idents = $user->list_identities();
+
+ $this->assertCount(2, $idents);
+ }
+
+ /**
+ * Test failed_login() and is_locked()
+ */
+ function test_failed_login()
+ {
+ self::initDB('init');
+
+ $user = new rcube_user(1);
+
+ $user->failed_login();
+
+ $user = new rcube_user(1);
+
+ $this->assertEquals(1, $user->data['failed_login_counter']);
+
+ $this->assertFalse($user->is_locked());
+ }
+
+ /**
+ * Test query()
+ */
+ function test_query()
+ {
+ self::initDB('init');
+
+ $this->assertNull(rcube_user::query('test', 'localhost'));
+
+ $user = rcube_user::query('test@example.com', 'localhost');
+
+ $this->assertEquals(1, $user->ID);
+ }
+
+ /**
+ * Test create()
+ */
+ function test_create()
+ {
+ self::initDB('init');
+
+ $user = rcube_user::create('new@example.com', 'localhost');
+
+ $this->assertSame('new@example.com', $user->get_username());
+
+ $user = new rcube_user($user->ID);
+
+ $idents = $user->list_identities();
+
+ $this->assertCount(1, $idents);
+ $this->assertSame('new@example.com', $idents[0]['email']);
+ $this->assertEquals(1, $idents[0]['standard']);
+ }
+
+ /**
+ * Test saved searches
+ */
+ function test_saved_searches()
+ {
+ $this->markTestIncomplete();
}
}
diff --git a/tests/Framework/Utils.php b/tests/Framework/Utils.php
index cacd9393c..42698e1c9 100644
--- a/tests/Framework/Utils.php
+++ b/tests/Framework/Utils.php
@@ -22,26 +22,26 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function data_valid_email()
{
- return array(
- array('email@domain.com', 'Valid email'),
- array('firstname.lastname@domain.com', 'Email contains dot in the address field'),
- array('email@subdomain.domain.com', 'Email contains dot with subdomain'),
- array('firstname+lastname@domain.com', 'Plus sign is considered valid character'),
- array('email@[123.123.123.123]', 'Square bracket around IP address'),
- array('email@[IPv6:::1]', 'Square bracket around IPv6 address (1)'),
- array('email@[IPv6:::1.2.3.4]', 'Square bracket around IPv6 address (2)'),
- array('email@[IPv6:2001:2d12:c4fe:5afe::1]', 'Square bracket around IPv6 address (3)'),
- array('"email"@domain.com', 'Quotes around email is considered valid'),
- array('1234567890@domain.com', 'Digits in address are valid'),
- array('email@domain-one.com', 'Dash in domain name is valid'),
- array('_______@domain.com', 'Underscore in the address field is valid'),
- array('email@domain.name', '.name is valid Top Level Domain name'),
- array('email@domain.co.jp', 'Dot in Top Level Domain name also considered valid (use co.jp as example here)'),
- array('firstname-lastname@domain.com', 'Dash in address field is valid'),
- array('test@xn--e1aaa0cbbbcacac.xn--p1ai', 'IDNA domain'),
- array('あいうえお@domain.com', 'Unicode char as address'),
- array('test@domain.2legit2quit', 'Extended TLD'),
- );
+ return [
+ ['email@domain.com', 'Valid email'],
+ ['firstname.lastname@domain.com', 'Email contains dot in the address field'],
+ ['email@subdomain.domain.com', 'Email contains dot with subdomain'],
+ ['firstname+lastname@domain.com', 'Plus sign is considered valid character'],
+ ['email@[123.123.123.123]', 'Square bracket around IP address'],
+ ['email@[IPv6:::1]', 'Square bracket around IPv6 address (1)'],
+ ['email@[IPv6:::1.2.3.4]', 'Square bracket around IPv6 address (2)'],
+ ['email@[IPv6:2001:2d12:c4fe:5afe::1]', 'Square bracket around IPv6 address (3)'],
+ ['"email"@domain.com', 'Quotes around email is considered valid'],
+ ['1234567890@domain.com', 'Digits in address are valid'],
+ ['email@domain-one.com', 'Dash in domain name is valid'],
+ ['_______@domain.com', 'Underscore in the address field is valid'],
+ ['email@domain.name', '.name is valid Top Level Domain name'],
+ ['email@domain.co.jp', 'Dot in Top Level Domain name also considered valid (use co.jp as example here)'],
+ ['firstname-lastname@domain.com', 'Dash in address field is valid'],
+ ['test@xn--e1aaa0cbbbcacac.xn--p1ai', 'IDNA domain'],
+ ['あいうえお@domain.com', 'Unicode char as address'],
+ ['test@domain.2legit2quit', 'Extended TLD'],
+ ];
}
/**
@@ -49,32 +49,32 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function data_invalid_email()
{
- return array(
- array('plainaddress', 'Missing @ sign and domain'),
- array('#@%^%#$@#$@#.com', 'Garbage'),
- array('@domain.com', 'Missing username'),
- array('Joe Smith ', 'Encoded html within email is invalid'),
- array('email.domain.com', 'Missing @'),
- array('email@domain@domain.com', 'Two @ sign'),
- array('.email@domain.com', 'Leading dot in address is not allowed'),
- array('email.@domain.com', 'Trailing dot in address is not allowed'),
- array('email..email@domain.com', 'Multiple dots'),
- array('email@domain.com (Joe Smith)', 'Text followed email is not allowed'),
- array('email@domain', 'Missing top level domain (.com/.net/.org/etc)'),
- array('email@-domain.com', 'Leading dash in front of domain is invalid'),
-// array('email@domain.web', '.web is not a valid top level domain'),
- array('email@123.123.123.123', 'IP address without brackets'),
- array('email@2001:2d12:c4fe:5afe::1', 'IPv6 address without brackets'),
- array('email@IPv6:2001:2d12:c4fe:5afe::1', 'IPv6 address without brackets (2)'),
- array('email@[111.222.333.44444]', 'Invalid IP format'),
- array('email@[111.222.255.257]', 'Invalid IP format (2)'),
- array('email@[.222.255.257]', 'Invalid IP format (3)'),
- array('email@[::1]', 'Invalid IPv6 format (1)'),
- array('email@[IPv6:2001:23x2:1]', 'Invalid IPv6 format (2)'),
- array('email@[IPv6:1111:2222:33333::4444:5555]', 'Invalid IPv6 format (3)'),
- array('email@[IPv6:1111::3333::4444:5555]', 'Invalid IPv6 format (4)'),
- array('email@domain..com', 'Multiple dot in the domain portion is invalid'),
- );
+ return [
+ ['plainaddress', 'Missing @ sign and domain'],
+ ['#@%^%#$@#$@#.com', 'Garbage'],
+ ['@domain.com', 'Missing username'],
+ ['Joe Smith ', 'Encoded html within email is invalid'],
+ ['email.domain.com', 'Missing @'],
+ ['email@domain@domain.com', 'Two @ sign'],
+ ['.email@domain.com', 'Leading dot in address is not allowed'],
+ ['email.@domain.com', 'Trailing dot in address is not allowed'],
+ ['email..email@domain.com', 'Multiple dots'],
+ ['email@domain.com (Joe Smith)', 'Text followed email is not allowed'],
+ ['email@domain', 'Missing top level domain (.com/.net/.org/etc)'],
+ ['email@-domain.com', 'Leading dash in front of domain is invalid'],
+// ['email@domain.web', '.web is not a valid top level domain'],
+ ['email@123.123.123.123', 'IP address without brackets'],
+ ['email@2001:2d12:c4fe:5afe::1', 'IPv6 address without brackets'],
+ ['email@IPv6:2001:2d12:c4fe:5afe::1', 'IPv6 address without brackets (2)'],
+ ['email@[111.222.333.44444]', 'Invalid IP format'],
+ ['email@[111.222.255.257]', 'Invalid IP format (2)'],
+ ['email@[.222.255.257]', 'Invalid IP format (3)'],
+ ['email@[::1]', 'Invalid IPv6 format (1)'],
+ ['email@[IPv6:2001:23x2:1]', 'Invalid IPv6 format (2)'],
+ ['email@[IPv6:1111:2222:33333::4444:5555]', 'Invalid IPv6 format (3)'],
+ ['email@[IPv6:1111::3333::4444:5555]', 'Invalid IPv6 format (4)'],
+ ['email@domain..com', 'Multiple dot in the domain portion is invalid'],
+ ];
}
/**
@@ -98,16 +98,16 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function data_valid_ip()
{
- return array(
- array('0.0.0.0'),
- array('123.123.123.123'),
- array('::'),
- array('::1'),
- array('::1.2.3.4'),
- array('2001:2d12:c4fe:5afe::1'),
- array('2001::'),
- array('2001::1'),
- );
+ return [
+ ['0.0.0.0'],
+ ['123.123.123.123'],
+ ['::'],
+ ['::1'],
+ ['::1.2.3.4'],
+ ['2001:2d12:c4fe:5afe::1'],
+ ['2001::'],
+ ['2001::1'],
+ ];
}
/**
@@ -115,18 +115,18 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function data_invalid_ip()
{
- return array(
- array(''),
- array(0),
- array('123.123.123.1234'),
- array('1.1.1.1.1'),
- array('::1.2.3.260'),
- array('::1.0'),
- array(':::1'),
- array('2001:::1'),
- array('2001::c4fe:5afe::1'),
- array(':c4fe:5afe:1'),
- );
+ return [
+ [''],
+ [0],
+ ['123.123.123.1234'],
+ ['1.1.1.1.1'],
+ ['::1.2.3.260'],
+ ['::1.0'],
+ [':::1'],
+ ['2001:::1'],
+ ['2001::c4fe:5afe::1'],
+ [':c4fe:5afe:1'],
+ ];
}
/**
@@ -150,17 +150,17 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function data_rep_specialchars_output()
{
- return array(
- array('', '', 'abc', 'abc'),
- array('', '', '?', '?'),
- array('', '', '"', '"'),
- array('', '', '<', '<'),
- array('', '', '>', '>'),
- array('', '', '&', '&'),
- array('', '', '&', '&'),
- array('', '', '', '<a>'),
- array('', 'remove', '', ''),
- );
+ return [
+ ['', '', 'abc', 'abc'],
+ ['', '', '?', '?'],
+ ['', '', '"', '"'],
+ ['', '', '<', '<'],
+ ['', '', '>', '>'],
+ ['', '', '&', '&'],
+ ['', '', '&', '&'],
+ ['', '', '', '<a>'],
+ ['', 'remove', '', ''],
+ ];
}
/**
@@ -306,11 +306,11 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function test_explode_quoted_string()
{
- $data = array(
- '"a,b"' => array('"a,b"'),
- '"a,b","c,d"' => array('"a,b"','"c,d"'),
- '"a,\\"b",d' => array('"a,\\"b"', 'd'),
- );
+ $data = [
+ '"a,b"' => ['"a,b"'],
+ '"a,b","c,d"' => ['"a,b"','"c,d"'],
+ '"a,\\"b",d' => ['"a,\\"b"', 'd'],
+ ];
foreach ($data as $text => $res) {
$result = rcube_utils::explode_quoted_string(',', $text);
@@ -323,7 +323,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function test_explode_quoted_string_compat()
{
- $data = array('', 'a,b,c', 'a', ',', ',a');
+ $data = ['', 'a,b,c', 'a', ',', ',a'];
foreach ($data as $text) {
$result = rcube_utils::explode_quoted_string(',', $text);
@@ -336,17 +336,17 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function test_get_boolean()
{
- $input = array(
+ $input = [
false, 'false', '0', 'no', 'off', 'nein', 'FALSE', '', null,
- );
+ ];
foreach ($input as $idx => $value) {
$this->assertFalse(rcube_utils::get_boolean($value), "Invalid result for $idx test item");
}
- $input = array(
+ $input = [
true, 'true', '1', 1, 'yes', 'anything', 1000,
- );
+ ];
foreach ($input as $idx => $value) {
$this->assertTrue(rcube_utils::get_boolean($value), "Invalid result for $idx test item");
@@ -358,11 +358,11 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function test_file2class()
{
- $test = array(
- array('', '', 'unknown'),
- array('text', 'text', 'text'),
- array('image/png', 'image.png', 'image png'),
- );
+ $test = [
+ ['', '', 'unknown'],
+ ['text', 'text', 'text'],
+ ['image/png', 'image.png', 'image png'],
+ ];
foreach ($test as $v) {
$result = rcube_utils::file2class($v[0], $v[1]);
@@ -378,7 +378,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
// this test depends on system timezone if not set
date_default_timezone_set('UTC');
- $test = array(
+ $test = [
'1' => 1,
'' => 0,
'abc-555' => 0,
@@ -392,7 +392,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
'20130422' => 1366588800,
'2013/06/21 12:00:00 UTC' => 1371816000,
'2013/06/21 12:00:00 Europe/Berlin' => 1371808800,
- );
+ ];
foreach ($test as $datetime => $ts) {
$result = rcube_utils::strtotime($datetime);
@@ -405,7 +405,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function test_anytodatetime()
{
- $test = array(
+ $test = [
'2013-04-22' => '2013-04-22',
'2013/04/22' => '2013-04-22',
'2013.04.22' => '2013-04-22',
@@ -419,26 +419,26 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
'01-01-1900' => '1900-01-01',
'01/30/1960' => '1960-01-30',
'1960.12.11 01:02:00' => '1960-12-11',
- );
+ ];
foreach ($test as $datetime => $ts) {
$result = rcube_utils::anytodatetime($datetime);
$this->assertSame($ts, $result ? $result->format('Y-m-d') : false, "Error parsing date: $datetime");
}
- $test = array(
+ $test = [
'12/11/2013 01:02:00' => '2013-11-12 01:02:00',
'1960.12.11 01:02:00' => '1960-12-11 01:02:00',
- );
+ ];
foreach ($test as $datetime => $ts) {
$result = rcube_utils::anytodatetime($datetime);
$this->assertSame($ts, $result ? $result->format('Y-m-d H:i:s') : false, "Error parsing date: $datetime");
}
- $test = array(
+ $test = [
'Sun, 4 Mar 2018 03:32:08 +0300 (MSK)' => '2018-03-04 03:32:08 +0300',
- );
+ ];
foreach ($test as $datetime => $ts) {
$result = rcube_utils::anytodatetime($datetime);
@@ -452,13 +452,13 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
function test_anytodatetime_timezone()
{
$tz = new DateTimeZone('Europe/Helsinki');
- $test = array(
+ $test = [
'Jan 1st 2014 +0800' => '2013-12-31 18:00', // result in target timezone
'Jan 1st 14 45:42' => '2014-01-01 00:00', // force fallback to rcube_utils::strtotime()
'Jan 1st 2014 UK' => '2014-01-01 00:00',
'1520587800' => '2018-03-09 11:30', // unix timestamp conversion
'Invalid date' => false,
- );
+ ];
foreach ($test as $datetime => $ts) {
$result = rcube_utils::anytodatetime($datetime, $tz);
@@ -472,12 +472,12 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function test_format_datestr()
{
- $test = array(
- array('abc-555', 'abc', 'abc-555'),
- array('2013-04-22', 'Y-m-d', '2013-04-22'),
- array('22/04/2013', 'd/m/Y', '2013-04-22'),
- array('4.22.2013', 'm.d.Y', '2013-04-22'),
- );
+ $test = [
+ ['abc-555', 'abc', 'abc-555'],
+ ['2013-04-22', 'Y-m-d', '2013-04-22'],
+ ['22/04/2013', 'd/m/Y', '2013-04-22'],
+ ['4.22.2013', 'm.d.Y', '2013-04-22'],
+ ];
foreach ($test as $data) {
$result = rcube_utils::format_datestr($data[0], $data[1]);
@@ -490,13 +490,13 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function test_tokenize_string()
{
- $test = array(
- '' => array(),
- 'abc d' => array('abc'),
- 'abc de' => array('abc','de'),
- 'äàé;êöü-xyz' => array('äàé','êöü','xyz'),
- '日期格式' => array('日期格式'),
- );
+ $test = [
+ '' => [],
+ 'abc d' => ['abc'],
+ 'abc de' => ['abc','de'],
+ 'äàé;êöü-xyz' => ['äàé','êöü','xyz'],
+ '日期格式' => ['日期格式'],
+ ];
foreach ($test as $input => $output) {
$result = rcube_utils::tokenize_string($input);
@@ -509,7 +509,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function test_normalize_string()
{
- $test = array(
+ $test = [
'' => '',
'abc def' => 'abc def',
'ÇçäâàåæéêëèïîìÅÉöôòüûùÿøØáíóúñÑÁÂÀãÃÊËÈÍÎÏÓÔõÕÚÛÙýÝ' => 'ccaaaaaeeeeiiiaeooouuuyooaiounnaaaaaeeeiiioooouuuyy',
@@ -519,7 +519,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
'Xoe' => 'xo',
'Xue' => 'xu',
'项目' => '项目',
- );
+ ];
// this test fails on PHP 5.3.3
if (PHP_VERSION_ID > 50303) {
@@ -538,17 +538,17 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function test_words_match()
{
- $test = array(
- array('', 'test', false),
- array('test', 'test', true),
- array('test', 'none', false),
- array('test', 'test xyz', false),
- array('test xyz', 'test xyz', true),
- array('this is test', 'test', true),
+ $test = [
+ ['', 'test', false],
+ ['test', 'test', true],
+ ['test', 'none', false],
+ ['test', 'test xyz', false],
+ ['test xyz', 'test xyz', true],
+ ['this is test', 'test', true],
// try some binary content
- array('this is test ' . base64_decode('R0lGODlhDwAPAIAAAMDAwAAAACH5BAEAAAAALAAAAAAPAA8AQAINhI+py+0Po5y02otnAQA7'), 'test', true),
- array('this is test ' . base64_decode('R0lGODlhDwAPAIAAAMDAwAAAACH5BAEAAAAALAAAAAAPAA8AQAINhI+py+0Po5y02otnAQA7'), 'none', false),
- );
+ ['this is test ' . base64_decode('R0lGODlhDwAPAIAAAMDAwAAAACH5BAEAAAAALAAAAAAPAA8AQAINhI+py+0Po5y02otnAQA7'), 'test', true],
+ ['this is test ' . base64_decode('R0lGODlhDwAPAIAAAMDAwAAAACH5BAEAAAAALAAAAAAPAA8AQAINhI+py+0Po5y02otnAQA7'), 'none', false],
+ ];
foreach ($test as $idx => $params) {
$result = rcube_utils::words_match($params[0], $params[1]);
@@ -562,18 +562,18 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
function test_is_absolute_path()
{
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
- $test = array(
+ $test = [
'' => false,
"C:\\" => true,
'some/path' => false,
- );
+ ];
}
else {
- $test = array(
+ $test = [
'' => false,
'/path' => true,
'some/path' => false,
- );
+ ];
}
foreach ($test as $input => $output) {
@@ -605,26 +605,26 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
* and https://github.com/true/php-punycode/blob/master/tests/PunycodeTest.php for more Test-Data
*/
- return array(
- array('test@vermögensberater', 'test@xn--vermgensberater-ctb'),
- array('test@vermögensberatung', 'test@xn--vermgensberatung-pwb'),
- array('test@グーグル', 'test@xn--qcka1pmc'),
- array('test@谷歌', 'test@xn--flw351e'),
- array('test@中信', 'test@xn--fiq64b'),
- array('test@рф.ru', 'test@xn--p1ai.ru'),
- array('test@δοκιμή.gr', 'test@xn--jxalpdlp.gr'),
- array('test@gwóźdź.pl', 'test@xn--gwd-hna98db.pl'),
- array('рф.ru@рф.ru', 'рф.ru@xn--p1ai.ru'),
- array('vermögensberater', 'xn--vermgensberater-ctb'),
- array('vermögensberatung', 'xn--vermgensberatung-pwb'),
- array('グーグル', 'xn--qcka1pmc'),
- array('谷歌', 'xn--flw351e'),
- array('中信', 'xn--fiq64b'),
- array('рф.ru', 'xn--p1ai.ru'),
- array('δοκιμή.gr', 'xn--jxalpdlp.gr'),
- array('gwóźdź.pl', 'xn--gwd-hna98db.pl'),
- array('fußball.de', 'xn--fuball-cta.de'),
- );
+ return [
+ ['test@vermögensberater', 'test@xn--vermgensberater-ctb'],
+ ['test@vermögensberatung', 'test@xn--vermgensberatung-pwb'],
+ ['test@グーグル', 'test@xn--qcka1pmc'],
+ ['test@谷歌', 'test@xn--flw351e'],
+ ['test@中信', 'test@xn--fiq64b'],
+ ['test@рф.ru', 'test@xn--p1ai.ru'],
+ ['test@δοκιμή.gr', 'test@xn--jxalpdlp.gr'],
+ ['test@gwóźdź.pl', 'test@xn--gwd-hna98db.pl'],
+ ['рф.ru@рф.ru', 'рф.ru@xn--p1ai.ru'],
+ ['vermögensberater', 'xn--vermgensberater-ctb'],
+ ['vermögensberatung', 'xn--vermgensberatung-pwb'],
+ ['グーグル', 'xn--qcka1pmc'],
+ ['谷歌', 'xn--flw351e'],
+ ['中信', 'xn--fiq64b'],
+ ['рф.ru', 'xn--p1ai.ru'],
+ ['δοκιμή.gr', 'xn--jxalpdlp.gr'],
+ ['gwóźdź.pl', 'xn--gwd-hna98db.pl'],
+ ['fußball.de', 'xn--fuball-cta.de'],
+ ];
}
/**
@@ -665,12 +665,12 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
*/
function data_parse_host()
{
- return array(
- array('%z', 'hostname', 'hostname'),
- array('%z', 'domain.tld', 'domain.tld'),
- array('%z', 'host.domain.tld', 'domain.tld'),
- array('%z', 'host1.host2.domain.tld', 'host2.domain.tld'),
- );
+ return [
+ ['%z', 'hostname', 'hostname'],
+ ['%z', 'domain.tld', 'domain.tld'],
+ ['%z', 'host.domain.tld', 'domain.tld'],
+ ['%z', 'host1.host2.domain.tld', 'host2.domain.tld'],
+ ];
}
/**
diff --git a/tests/Framework/VCard.php b/tests/Framework/VCard.php
index 4f3e84677..313573aec 100644
--- a/tests/Framework/VCard.php
+++ b/tests/Framework/VCard.php
@@ -112,6 +112,9 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
// https://github.com/roundcube/roundcubemail/issues/1934
$vcards2 = rcube_vcard::import(file_get_contents($this->_srcpath('thebat.vcf')));
$this->assertEquals("Iksiñski", $vcards2[0]->surname, "Detect charset in encoded values");
+
+ $vcards[0]->reset();
+ // TODO: Test reset() method
}
function test_import_photo_encoding()
diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php
index c2f1c22e6..ab883489c 100644
--- a/tests/Framework/Washtml.php
+++ b/tests/Framework/Washtml.php
@@ -156,36 +156,36 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
*/
function test_lists()
{
- $data = array(
- array(
+ $data = [
+ [
"- First
- Second
- First sub
- Third
",
"- First
- Second
- First sub
- Third
"
- ),
- array(
+ ],
+ [
"- First
- First sub
",
"- First
- First sub
",
- ),
- array(
+ ],
+ [
"- First
- First sub
",
"- First
- First sub
",
- ),
- array(
+ ],
+ [
"- First
- First sub
- sub sub
",
"- First
- First sub
- sub sub
",
- ),
- array(
+ ],
+ [
"- First
- second
- sub sub
",
"- First
- second
- sub sub
",
- ),
- array(
+ ],
+ [
"
",
"
",
- ),
- array(
+ ],
+ [
"
",
"
",
- ),
- );
+ ],
+ ];
foreach ($data as $element) {
rcube_washtml::fix_broken_lists($element[0]);
@@ -239,7 +239,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
";
- $washer = new rcube_washtml(array('html_elements' => array('body')));
+ $washer = new rcube_washtml(['html_elements' => ['body']]);
$washed = $washer->wash($html);
$this->assertRegExp('|bgcolor="#fff"|', $washed, "Body bgcolor attribute");
@@ -585,13 +585,13 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
*/
function test_extlinks()
{
- $html = array(
- array("", true),
- array("", false),
- array("
", true),
- array("
", false),
- array('', true),
- );
+ $html = [
+ ["", true],
+ ["", false],
+ ["
", true],
+ ["
", false],
+ ['', true],
+ ];
foreach ($html as $item) {
$washer = new rcube_washtml;
@@ -601,7 +601,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
}
foreach ($html as $item) {
- $washer = new rcube_washtml(array('allow_remote' => true));
+ $washer = new rcube_washtml(['allow_remote' => true]);
$washed = $washer->wash($item[0]);
$this->assertFalse($washer->extlinks);
@@ -624,7 +624,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
*/
function test_css_prefix()
{
- $washer = new rcube_washtml(array('css_prefix' => 'test'));
+ $washer = new rcube_washtml(['css_prefix' => 'test']);
$html = ''
. ''
diff --git a/tests/Rcmail/Rcmail.php b/tests/Rcmail/Rcmail.php
index b840dea46..8d79d5d4e 100644
--- a/tests/Rcmail/Rcmail.php
+++ b/tests/Rcmail/Rcmail.php
@@ -131,23 +131,23 @@ class Rcmail_Rcmail extends ActionTestCase
);
$this->assertEquals(
'./?_task=cli&_action=test&_a=AA',
- $rcmail->url(array('action' => 'test', 'a' => 'AA')),
+ $rcmail->url(['action' => 'test', 'a' => 'AA']),
"Unprefixed parameters"
);
$this->assertEquals(
'./?_task=cli&_action=test&_b=BB',
- $rcmail->url(array('_action' => 'test', '_b' => 'BB', '_c' => null)),
+ $rcmail->url(['_action' => 'test', '_b' => 'BB', '_c' => null]),
"Prefixed parameters (skip empty)"
);
$this->assertEquals(
'/sub/?_task=cli&_action=test&_mode=ABS',
- $rcmail->url(array('_action' => 'test', '_mode' => 'ABS'), true),
+ $rcmail->url(['_action' => 'test', '_mode' => 'ABS'], true),
"Absolute URL"
);
$this->assertEquals(
'https://mail.example.org/sub/?_task=calendar&_action=test&_mode=FQ',
- $rcmail->url(array('task' => 'calendar', '_action' => 'test', '_mode' => 'FQ'), true, true),
+ $rcmail->url(['task' => 'calendar', '_action' => 'test', '_mode' => 'FQ'], true, true),
"Fully Qualified URL"
);
@@ -155,13 +155,13 @@ class Rcmail_Rcmail extends ActionTestCase
$_SERVER['SCRIPT_NAME'] = 'index.php';
$this->assertEquals(
'/?_task=cli&_action=test&_mode=ABS',
- $rcmail->url(array('_action' => 'test', '_mode' => 'ABS'), true),
+ $rcmail->url(['_action' => 'test', '_mode' => 'ABS'], true),
"Absolute URL (root)"
);
$_SERVER['SCRIPT_NAME'] = '';
$this->assertEquals(
'/?_task=cli&_action=test&_mode=ABS',
- $rcmail->url(array('_action' => 'test', '_mode' => 'ABS'), true),
+ $rcmail->url(['_action' => 'test', '_mode' => 'ABS'], true),
"Absolute URL (root)"
);
@@ -169,7 +169,7 @@ class Rcmail_Rcmail extends ActionTestCase
$_SERVER['SERVER_PORT'] = '8080';
$this->assertEquals(
'http://mail.example.org:8080/?_task=cli&_action=test&_mode=ABS',
- $rcmail->url(array('_action' => 'test', '_mode' => 'ABS'), true, true),
+ $rcmail->url(['_action' => 'test', '_mode' => 'ABS'], true, true),
"Full URL with port"
);
}
diff --git a/tests/Rcmail/Sendmail.php b/tests/Rcmail/Sendmail.php
index d547253a6..251f6eff6 100644
--- a/tests/Rcmail/Sendmail.php
+++ b/tests/Rcmail/Sendmail.php
@@ -61,11 +61,11 @@ class Rcmail_RcmailSendmail extends ActionTestCase
function test_get_identity()
{
self::initDB('identities');
+ self::initUser();
$db = rcmail::get_instance()->get_dbh();
$query = $db->query('SELECT * FROM `identities` WHERE `standard` = 1 LIMIT 1');
$identity = $db->fetch_assoc($query);
-
$sendmail = new rcmail_sendmail();
$result = $sendmail->get_identity($identity['identity_id']);
@@ -88,43 +88,43 @@ class Rcmail_RcmailSendmail extends ActionTestCase
*/
function data_email_input_format()
{
- return array(
- array(
+ return [
+ [
'name ',
'name ',
'UTF-8'
- ),
- array(
+ ],
+ [
'"first last" ',
'first last ',
'UTF-8'
- ),
- array(
+ ],
+ [
'"first last" , test2@domain.tld,',
'first last , test2@domain.tld',
'UTF-8'
- ),
- array(
+ ],
+ [
'',
'test@domain.tld',
'UTF-8'
- ),
- array(
+ ],
+ [
'test@domain.tld',
'test@domain.tld',
'UTF-8'
- ),
- array(
+ ],
+ [
'ö ',
'ö ',
null
- ),
- array(
+ ],
+ [
base64_decode('GyRCLWo7M3l1OSk2SBsoQg==') . ' ',
'=?ISO-2022-JP?B?GyRCLWo7M3l1OSk2SBsoQg==?= ',
'ISO-2022-JP'
- ),
- );
+ ],
+ ];
}
/**
@@ -352,23 +352,23 @@ class Rcmail_RcmailSendmail extends ActionTestCase
*/
function test_identity_select_return_path()
{
- $identities = array(
- array(
+ $identities = [
+ [
'name' => 'Test',
'email_ascii' => 'addr@domain.tld',
'ident' => 'Test ',
- ),
- array(
+ ],
+ [
'name' => 'Test',
'email_ascii' => 'thing@domain.tld',
'ident' => 'Test ',
- ),
- array(
+ ],
+ [
'name' => 'Test',
'email_ascii' => 'other@domain.tld',
'ident' => 'Test ',
- ),
- );
+ ],
+ ];
$message = new stdClass;
$message->headers = new rcube_message_header;
@@ -388,28 +388,28 @@ class Rcmail_RcmailSendmail extends ActionTestCase
*/
function test_identity_select_more()
{
- $identities = array(
- array(
+ $identities = [
+ [
'name' => 'Test 1',
'email_ascii' => 'addr1@domain.tld',
'ident' => 'Test 1 ',
- ),
- array(
+ ],
+ [
'name' => 'Test 2',
'email_ascii' => 'addr2@domain.tld',
'ident' => 'Test 2 ',
- ),
- array(
+ ],
+ [
'name' => 'Test 3',
'email_ascii' => 'addr3@domain.tld',
'ident' => 'Test 3 ',
- ),
- array(
+ ],
+ [
'name' => 'Test 4',
'email_ascii' => 'addr2@domain.tld',
'ident' => 'Test 4 ',
- ),
- );
+ ],
+ ];
$message = new stdClass;
$message->headers = new rcube_message_header;
diff --git a/tests/src/sample.rtf b/tests/src/sample.rtf
new file mode 100644
index 000000000..6fa678940
--- /dev/null
+++ b/tests/src/sample.rtf
@@ -0,0 +1,18 @@
+{\rtf1\mac\deff2 {\fonttbl{\f0\fswiss Chicago;}{\f2\froman New York;}{\f3\fswiss Geneva;}{\f4\fmodern Monaco;}{\f11\fnil Cairo;}{\f13\fnil Zapf Dingbats;}{\f14\fnil Bookman;}{\f15\fnil N Helvetica Narrow;}{\f16\fnil Palatino;}{\f18\fnil Zapf Chancery;}
+{\f20\froman Times;}{\f21\fswiss Helvetica;}{\f22\fmodern Courier;}{\f23\ftech Symbol;}{\f33\fnil Avant Garde;}{\f34\fnil New Century Schlbk;}{\f1297\fnil GoudyHundred;}{\f1602\fnil BlackChancery;}{\f2515\fnil MT Extra;}{\f4950\fnil TTYFont;}
+{\f11132\fnil InsigniaLQmono;}{\f11133\fnil InsigniaLQprop;}{\f32500\fnil VT320;}{\f32525\fnil VT100;}}{\colortbl\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;
+\red255\green255\blue0;\red255\green255\blue255;}{\stylesheet{\s250\li720 \f21\fs20\ul \sbasedon0\snext0 heading 6;}{\s251\li720 \b\f21\fs20 \sbasedon0\snext0 heading 5;}{\s252\li360 \f21\ul \sbasedon0\snext0 heading 4;}{\s253\li360 \b\f21
+\sbasedon0\snext0 heading 3;}{\s254\sb120 \b\f21 \sbasedon0\snext0 heading 2;}{\s255\sb240 \b\f21\ul \sbasedon0\snext0 heading 1;}{\f21 \sbasedon222\snext0 Normal;}{\s2 \b\f21\cf1 \sbasedon0\snext2 Anchor;}}{\info{\author Alex Skolnick}}
+\margl720\margr720\ftnbj\fracwidth \sectd \sbknone\linemod0\linex0\cols1\endnhere \pard\plain \s255\sb240 \b\f21\ul Heading 1\par
+\pard\plain \f21 This is the first normal paragraph!\par
+\pard\plain \s254\sb120 \b\f21 Heading 2\par
+\pard\plain \s253\li360 \b\f21 Heading 3\par
+\pard\plain \s252\li360 \f21\ul Heading 4\par
+\pard\plain \s251\li720 \b\f21\fs20 Heading 5\par
+\pard\plain \s250\li720 \f21\fs20\ul Heading 6\par
+\pard\plain \f21 This is a chunk of normal text.\par
+This is a chunk of normal text with specials, &, <, and >.\par
+This is a second paragraph.\par
+This is text with embedded {\b bold}, {\i italic}, and {\ul underline} styles.\par
+Here is the {\cf1 anchor} style. And here is the {\cf5 Image} style.\par
+}
\ No newline at end of file