Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Testing GH change fetching #1

Closed
wants to merge 10 commits into from
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
CHANGELOG Roundcube Webmail
===========================

RELEASE 1.2-rc
--------------
- Managesieve: Refactored script parser to be 100x faster
- Enigma: added option to force users to use signing/encryption
- Enigma: Added option to attach public keys to sent mail (#5152)
- Enigma: Handle messages with text before an encrypted block (#5149)
- Enigma: Handle encrypted/signed content inside message/rfc822 attachments
Expand Down Expand Up @@ -33,6 +36,8 @@ CHANGELOG Roundcube Webmail
- newmail_notifier: Refactor desktop notifications
- Fix so contactlist_fields option can be set via config file
- Fix so SPECIAL-USE assignments are forced only until user sets special folders (#4782)
- Fix performance in reverting order of THREAD result
- Fix converting mail addresses with @www. into mailto links (#5197)

RELEASE 1.2-beta
----------------
Expand Down
2 changes: 1 addition & 1 deletion config/defaults.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@
// NOTE: Use folder names with namespace prefix (INBOX. on Courier-IMAP)
$config['trash_mbox'] = 'Trash';

// automatically create the above listed default folders on first login
// automatically create the above listed default folders on user login
$config['create_default_folders'] = false;

// protect the default folders from renames, deletes, and subscription changes
Expand Down
11 changes: 11 additions & 0 deletions plugins/enigma/config.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,14 @@ $config['enigma_password_time'] = 5;
// To solve that a hardware entropy generator or
// an entropy gathering daemon may be installed (e.g. randomsound).
$config['enigma_keygen_server'] = false;

// With this option you can lock composing options
// of the plugin forcing the user to use configured settings.
// The array accepts: 'sign', 'encrypt', 'pubkey'.
//
// For example, to force your users to sign every email,
// you should set:
// - enigma_sign_all = true
// - enigma_options_lock = array('sign')
// - dont_override = array('enigma_sign_all')
$config['enigma_options_lock'] = array();
52 changes: 42 additions & 10 deletions plugins/enigma/lib/enigma_ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -717,23 +717,36 @@ private function compose_ui()
'height' => 32
), 'toolbar');

$locks = (array) $this->rc->config->get('enigma_options_lock');
$menu = new html_table(array('cols' => 2));
$chbox = new html_checkbox(array('value' => 1));

$menu->add(null, html::label(array('for' => 'enigmasignopt'),
rcube::Q($this->enigma->gettext('signmsg'))));
$menu->add(null, $chbox->show($this->rc->config->get('enigma_sign_all') ? 1 : 0,
array('name' => '_enigma_sign', 'id' => 'enigmasignopt')));
array(
'name' => '_enigma_sign',
'id' => 'enigmasignopt',
'disabled' => in_array('sign', $locks),
)));

$menu->add(null, html::label(array('for' => 'enigmaencryptopt'),
rcube::Q($this->enigma->gettext('encryptmsg'))));
$menu->add(null, $chbox->show($this->rc->config->get('enigma_encrypt_all') ? 1 : 0,
array('name' => '_enigma_encrypt', 'id' => 'enigmaencryptopt')));
array(
'name' => '_enigma_encrypt',
'id' => 'enigmaencryptopt',
'disabled' => in_array('encrypt', $locks),
)));

$menu->add(null, html::label(array('for' => 'enigmaattachpubkeyopt'),
rcube::Q($this->enigma->gettext('attachpubkeymsg'))));
$menu->add(null, $chbox->show($this->rc->config->get('enigma_attach_pubkey') ? 1 : 0,
array('name' => '_enigma_attachpubkey', 'id' => 'enigmaattachpubkeyopt')));
$menu->add(null, $chbox->show($this->rc->config->get('enigma_attach_pubkey') ? 1 : 0,
array(
'name' => '_enigma_attachpubkey',
'id' => 'enigmaattachpubkeyopt',
'disabled' => in_array('pubkey', $locks),
)));

$menu = html::div(array('id' => 'enigmamenu', 'class' => 'popupmenu'), $menu->show());

Expand Down Expand Up @@ -938,20 +951,34 @@ function message_output($p)
*/
function message_ready($p)
{
$savedraft = !empty($_POST['_draft']) && empty($_GET['_saveonly']);
$savedraft = !empty($_POST['_draft']) && empty($_GET['_saveonly']);
$sign_enable = (bool) rcube_utils::get_input_value('_enigma_sign', rcube_utils::INPUT_POST);
$encrypt_enable = (bool) rcube_utils::get_input_value('_enigma_encrypt', rcube_utils::INPUT_POST);
$pubkey_enable = (bool) rcube_utils::get_input_value('_enigma_attachpubkey', rcube_utils::INPUT_POST);
$locks = (array) $this->rc->config->get('enigma_options_lock');

if (in_array('sign', $locks)) {
$sign_enable = (bool) $this->rc->config->get('enigma_sign_all');
}
if (in_array('encrypt', $locks)) {
$encrypt_enable = (bool) $this->rc->config->get('enigma_encrypt_all');
}
if (in_array('pubkey', $locks)) {
$pubkey_enable = (bool) $this->rc->config->get('enigma_attach_pubkey');
}

if (!$savedraft && rcube_utils::get_input_value('_enigma_attachpubkey', rcube_utils::INPUT_POST)) {
if (!$savedraft && $pubkey_enable) {
$this->enigma->load_engine();
$this->enigma->engine->attach_public_key($p['message']);
}

if (!$savedraft && rcube_utils::get_input_value('_enigma_sign', rcube_utils::INPUT_POST)) {
if (!$savedraft && $sign_enable) {
$this->enigma->load_engine();
$status = $this->enigma->engine->sign_message($p['message']);
$mode = 'sign';
}

if ((!$status instanceof enigma_error) && rcube_utils::get_input_value('_enigma_encrypt', rcube_utils::INPUT_POST)) {
if ((!$status instanceof enigma_error) && $encrypt_enable) {
$this->enigma->load_engine();
$status = $this->enigma->engine->encrypt_message($p['message'], null, $savedraft);
$mode = 'encrypt';
Expand Down Expand Up @@ -996,6 +1023,7 @@ function message_compose($p)
}

$engine = $this->enigma->engine;
$locks = (array) $this->rc->config->get('enigma_options_lock');

// Decryption status
foreach ($engine->decryptions as $status) {
Expand All @@ -1021,8 +1049,12 @@ function message_compose($p)
}

// Check sign/ecrypt options for signed/encrypted drafts
$this->rc->output->set_env('enigma_force_encrypt', !empty($engine->decryptions));
$this->rc->output->set_env('enigma_force_sign', !empty($engine->signatures));
if (!in_array('encrypt', $locks)) {
$this->rc->output->set_env('enigma_force_encrypt', !empty($engine->decryptions));
}
if (!in_array('sign', $locks)) {
$this->rc->output->set_env('enigma_force_sign', !empty($engine->signatures));
}

return $p;
}
Expand Down
58 changes: 30 additions & 28 deletions plugins/managesieve/lib/Roundcube/rcube_sieve_script.php
Original file line number Diff line number Diff line change
Expand Up @@ -966,25 +966,33 @@ private function test_tokens(&$tokens)
$result = array();

for ($i=0, $len=count($tokens); $i<$len; $i++) {
if (!is_array($tokens[$i]) && preg_match('/^:comparator$/i', $tokens[$i])) {
$test['comparator'] = $tokens[++$i];
}
else if (!is_array($tokens[$i]) && preg_match('/^:(count|value)$/i', $tokens[$i])) {
$test['type'] = strtolower(substr($tokens[$i], 1)) . '-' . $tokens[++$i];
}
else if (!is_array($tokens[$i]) && preg_match('/^:(is|contains|matches|regex)$/i', $tokens[$i])) {
$test['type'] = strtolower(substr($tokens[$i], 1));
}
else if (!is_array($tokens[$i]) && preg_match('/^:index$/i', $tokens[$i])) {
$test['index'] = intval($tokens[++$i]);
if ($tokens[$i+1] && preg_match('/^:last$/i', $tokens[$i+1])) {
$test['last'] = true;
$i++;
if (!is_array($tokens[$i]) && $tokens[$i][0] == ':') {
if (preg_match('/^:comparator$/i', $tokens[$i])) {
$test['comparator'] = $tokens[++$i];
continue;
}
}
else {
$result[] = $tokens[$i];
}

if (preg_match('/^:(count|value)$/i', $tokens[$i])) {
$test['type'] = strtolower(substr($tokens[$i], 1)) . '-' . $tokens[++$i];
continue;
}

if (preg_match('/^:(is|contains|matches|regex)$/i', $tokens[$i])) {
$test['type'] = strtolower(substr($tokens[$i], 1));
continue;
}

if (preg_match('/^:index$/i', $tokens[$i])) {
$test['index'] = intval($tokens[++$i]);
if ($tokens[$i+1] && preg_match('/^:last$/i', $tokens[$i+1])) {
$test['last'] = true;
$i++;
}
continue;
}
}

$result[] = $tokens[$i];
}

$tokens = $result;
Expand Down Expand Up @@ -1090,6 +1098,7 @@ static function tokenize($str, $num = 0, &$position = 0)
{
$result = array();
$length = strlen($str);
$mask = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:_';

// remove spaces from the beginning of the string
while ($position < $length && (!$num || $num === true || count($result) < $num)) {
Expand Down Expand Up @@ -1175,18 +1184,11 @@ static function tokenize($str, $num = 0, &$position = 0)
if ($position == $length) {
break 2;
}
if ($length - $position < 2) {
$result[] = substr($str, $position);
$position = $length;
break;
}

// tag/identifier/number
if (preg_match('/[a-zA-Z0-9:_]+/', $str, $m, PREG_OFFSET_CAPTURE, $position)
&& $m[0][1] == $position
) {
$atom = $m[0][0];
$position += strlen($atom);
if ($len = strspn($str, $mask, $position)) {
$atom = substr($str, $position, $len);
$position += $len;

if ($atom != 'text:') {
$result[] = $atom;
Expand Down
10 changes: 6 additions & 4 deletions program/include/rcmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ public function autocomplete_init()
/**
* Returns supported font-family specifications
*
* @param string $font Font name
* @param string $font Font name
*
* @param string|array Font-family specification array or string (if $font is used)
*/
Expand Down Expand Up @@ -2203,8 +2203,8 @@ public static function font_defs($font = null)
/**
* Create a human readable string for a number of bytes
*
* @param int Number of bytes
* @param string Size unit
* @param int $bytes Number of bytes
* @param string &$unit Size unit
*
* @return string Byte string
*/
Expand Down Expand Up @@ -2235,7 +2235,7 @@ public function show_bytes($bytes, &$unit = null)
/**
* Returns real size (calculated) of the message part
*
* @param rcube_message_part Message part
* @param rcube_message_part $part Message part
*
* @return string Part size (and unit)
*/
Expand Down Expand Up @@ -2319,6 +2319,8 @@ public static function get_uids($uids = null, $mbox = null, &$is_multifolder = f
* Get resource file content (with assets_dir support)
*
* @param string $name File name
*
* @return string File content
*/
public function get_resource_content($name)
{
Expand Down
16 changes: 9 additions & 7 deletions program/lib/Roundcube/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
class html
{
protected $tagname;
protected $content;
protected $attrib = array();
protected $allowed = array();
protected $content;

public static $doctype = 'xhtml';
public static $lc_tags = true;
public static $common_attrib = array('id','class','style','title','align','unselectable','tabindex','role');
public static $containers = array('iframe','div','span','p','h1','h2','h3','ul','form','textarea','table','thead','tbody','tr','th','td','style','script');
public static $containers = array('iframe','div','span','p','h1','h2','h3','ul','form','textarea','table','thead','tbody','tr','th','td','style','script');
public static $bool_attrib = array('checked','multiple','disabled','selected','autofocus','readonly');


/**
Expand Down Expand Up @@ -279,7 +280,7 @@ public static function br($attrib = array())
/**
* Create string with attributes
*
* @param array $attrib Associative arry with tag attributes
* @param array $attrib Associative array with tag attributes
* @param array $allowed List of allowed attributes
*
* @return string Valid attribute string
Expand Down Expand Up @@ -319,8 +320,9 @@ public static function attrib_string($attrib = array(), $allowed = null)
}

// attributes with no value
if (in_array($key, array('checked', 'multiple', 'disabled', 'selected', 'autofocus'))) {
if (in_array($key, self::$bool_attrib)) {
if ($value) {
// @TODO: minimize attribute in non-xhtml mode
$attrib_arr[] = $key . '="' . $key . '"';
}
}
Expand Down Expand Up @@ -460,7 +462,7 @@ class html_hiddenfield extends html
protected $tagname = 'input';
protected $type = 'hidden';
protected $allowed = array('type','name','value','onchange','disabled','readonly');
protected $fields_arr = array();
protected $fields = array();

/**
* Constructor
Expand All @@ -481,7 +483,7 @@ public function __construct($attrib = null)
*/
public function add($attrib)
{
$this->fields_arr[] = $attrib;
$this->fields[] = $attrib;
}

/**
Expand All @@ -492,7 +494,7 @@ public function add($attrib)
public function show()
{
$out = '';
foreach ($this->fields_arr as $attrib) {
foreach ($this->fields as $attrib) {
$out .= self::tag($this->tagname, array('type' => $this->type) + $attrib);
}

Expand Down
8 changes: 4 additions & 4 deletions program/lib/Roundcube/rcube_html2text.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ class rcube_html2text
*/
protected $search = array(
'/\r/', // Non-legal carriage return
'/^.*<body[^>]*>\n*/i', // Anything before <body>
'/<head[^>]*>.*?<\/head>/i', // <head>
'/<script[^>]*>.*?<\/script>/i', // <script>
'/<style[^>]*>.*?<\/style>/i', // <style>
'/^.*<body[^>]*>\n*/is', // Anything before <body>
'/<head[^>]*>.*?<\/head>/is', // <head>
'/<script[^>]*>.*?<\/script>/is', // <script>
'/<style[^>]*>.*?<\/style>/is', // <style>
'/[\n\t]+/', // Newlines and tabs
'/<p[^>]*>/i', // <p>
'/<\/p>[\s\n\t]*<div[^>]*>/i', // </p> before <div>
Expand Down
1 change: 0 additions & 1 deletion program/lib/Roundcube/rcube_result_index.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ public function revert()
return;
}

// @TODO: maybe do this in chunks
$data = $this->get();
$data = array_reverse($data);
$this->raw_data = implode(self::SEPARATOR_ELEMENT, $data);
Expand Down
19 changes: 4 additions & 15 deletions program/lib/Roundcube/rcube_result_thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,11 @@ public function revert()
return;
}

$this->meta['pos'] = array();
$datalen = strlen($this->raw_data);
$result = '';
$start = 0;

while (($pos = @strpos($this->raw_data, self::SEPARATOR_ELEMENT, $start))
|| ($start < $datalen && ($pos = $datalen))
) {
$len = $pos - $start;
$elem = substr($this->raw_data, $start, $len);
$start = $pos + 1;

$result = $elem . self::SEPARATOR_ELEMENT . $result;
}
$data = explode(self::SEPARATOR_ELEMENT, $this->raw_data);
$data = array_reverse($data);
$this->raw_data = implode(self::SEPARATOR_ELEMENT, $data);

$this->raw_data = rtrim($result, self::SEPARATOR_ELEMENT);
$this->meta['pos'] = array();
}

/**
Expand Down
Loading