From 39f40104f06cdcd9b8153b9fa4a32e5a7686bbb2 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 22 Mar 2013 18:53:24 +0100 Subject: Fix javascript error in IE9 when loading form with placeholders into an iframe (#1489008) --- program/js/common.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'program') diff --git a/program/js/common.js b/program/js/common.js index f9e945c05..7ad1891ec 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -720,10 +720,12 @@ jQuery.fn.placeholder = function(text) { var elem = $(this); this.title = text; + // Try HTML5 placeholder attribute first if ('placeholder' in this) { - elem.attr('placeholder', text); // Try HTML5 placeholder attribute first + elem.attr('placeholder', text); } - else { // Fallback to Javascript emulation of placeholder + // Fallback to Javascript emulation of placeholder + else { this._placeholder = text; elem.blur(function(e) { if ($.trim(elem.val()) == "") @@ -740,8 +742,13 @@ jQuery.fn.placeholder = function(text) { elem[(active ? 'addClass' : 'removeClass')]('placeholder').attr('spellcheck', active); }); - if (this != document.activeElement) // Do not blur currently focused element - elem.blur(); + // Do not blur currently focused element + // Catch "unspecified error" in IE9 (#1489008) + try { + if (this != document.activeElement) + elem.blur(); + } + catch(e) {} } }); }; -- cgit v1.2.3 From f38d15c700303b3d63e7ad1b06a418986ac815f9 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 22 Mar 2013 19:06:14 +0100 Subject: Better fix for IE9 issue with document.activeElement error (#1489008) --- program/js/app.js | 5 +++++ program/js/common.js | 8 ++------ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'program') diff --git a/program/js/app.js b/program/js/app.js index 0f1a72448..d194b7326 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -178,6 +178,11 @@ function rcube_webmail() parent.rcmail.env.frame_lock = null; } + // Makes that reference to document.activeElement do not throw + // "unspecified error" in IE9 (#1489008) + if (this.env.framed && bw.ie) + document.documentElement.focus(); + // enable general commands this.enable_command('close', 'logout', 'mail', 'addressbook', 'settings', 'save-pref', 'compose', 'undo', 'about', 'switch-task', 'menu-open', 'menu-save', true); diff --git a/program/js/common.js b/program/js/common.js index 7ad1891ec..1075225b4 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -743,12 +743,8 @@ jQuery.fn.placeholder = function(text) { }); // Do not blur currently focused element - // Catch "unspecified error" in IE9 (#1489008) - try { - if (this != document.activeElement) - elem.blur(); - } - catch(e) {} + if (this != document.activeElement) + elem.blur(); } }); }; -- cgit v1.2.3 From a85d54e1e801b07a152a717fbfca08c8eadad201 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Sat, 23 Mar 2013 17:57:58 +0100 Subject: Hack to reset PDO statement iterators after counting --- program/lib/Roundcube/rcube_db.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'program') diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php index 49bbe5c6e..ec61cb6b3 100644 --- a/program/lib/Roundcube/rcube_db.php +++ b/program/lib/Roundcube/rcube_db.php @@ -444,6 +444,7 @@ class rcube_db * * @param mixed $result Optional query handle * @return mixed Number of rows or false on failure + * @deprecated This method shows very poor performance and should be avoided. */ public function num_rows($result = null) { @@ -454,7 +455,9 @@ class rcube_db return $query ? intval($query->fetchColumn(0)) : false; } else { - return count($result->fetchAll()); + $num = count($result->fetchAll()); + $result->execute(); // re-execute query because there's no seek(0) + return $num; } } -- cgit v1.2.3 From 99cfba2e26a6a05190d45c287e7613485bd6833d Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 24 Mar 2013 09:06:29 +0100 Subject: Add some extension/mimetype aliases to fix some quirks in attachment type validation (#1488891) --- program/lib/Roundcube/rcube_mime.php | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'program') diff --git a/program/lib/Roundcube/rcube_mime.php b/program/lib/Roundcube/rcube_mime.php index b70d681c9..7cd520752 100644 --- a/program/lib/Roundcube/rcube_mime.php +++ b/program/lib/Roundcube/rcube_mime.php @@ -769,11 +769,35 @@ class rcube_mime // fallback to some well-known types most important for daily emails if (empty($mime_types)) { - $mime_extensions = @include(RCUBE_CONFIG_DIR . '/mimetypes.php'); - $mime_extensions += array('gif' => 'image/gif', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'tif' => 'image/tiff'); + $mime_extensions = (array) @include(RCUBE_CONFIG_DIR . '/mimetypes.php'); - foreach ($mime_extensions as $ext => $mime) + foreach ($mime_extensions as $ext => $mime) { $mime_types[$mime][] = $ext; + } + } + + // Add some known aliases that aren't included by some mime.types (#1488891) + // the order is important here so standard extensions have higher prio + $aliases = array( + 'image/gif' => array('gif'), + 'image/png' => array('png'), + 'image/x-png' => array('png'), + 'image/jpeg' => array('jpg', 'jpeg', 'jpe'), + 'image/jpg' => array('jpg', 'jpeg', 'jpe'), + 'image/pjpeg' => array('jpg', 'jpeg', 'jpe'), + 'image/tiff' => array('tif'), + 'message/rfc822' => array('eml'), + 'text/x-mail' => array('eml'), + ); + + foreach ($aliases as $mime => $exts) { + $mime_types[$mime] = array_unique(array_merge((array) $mime_types[$mime], $exts)); + + foreach ($exts as $ext) { + if (!isset($mime_extensions[$ext])) { + $mime_extensions[$ext] = $mime; + } + } } return $mimetype ? $mime_types[$mimetype] : $mime_extensions; -- cgit v1.2.3 From 17573916bcb4281b15f1acb27e4fae782ad52d2a Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Sun, 24 Mar 2013 11:52:55 +0100 Subject: Ensure backwards compatibility by considering old-style skin_path attribute for tags --- program/include/rcmail_output_html.php | 1 + 1 file changed, 1 insertion(+) (limited to 'program') diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php index 6100269b9..d8996edbf 100644 --- a/program/include/rcmail_output_html.php +++ b/program/include/rcmail_output_html.php @@ -873,6 +873,7 @@ class rcmail_output_html extends rcmail_output // include a file case 'include': $old_base_path = $this->base_path; + if (!empty($attrib['skin_path'])) $attrib['skinpath'] = $attrib['skin_path']; if ($path = $this->get_skin_file($attrib['file'], $skin_path, $attrib['skinpath'])) { $this->base_path = preg_replace('!plugins/\w+/!', '', $skin_path); // set base_path to core skin directory (not plugin's skin) $path = realpath($path); -- cgit v1.2.3 From 7889c57b772dbf722639894bd572c767424c8b84 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Sun, 24 Mar 2013 12:03:16 +0100 Subject: Match regex on multi-line sql statements --- program/lib/Roundcube/rcube_db.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'program') diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php index ec61cb6b3..4e6684c51 100644 --- a/program/lib/Roundcube/rcube_db.php +++ b/program/lib/Roundcube/rcube_db.php @@ -450,7 +450,7 @@ class rcube_db { if ($result || ($result === null && ($result = $this->last_result))) { // repeat query with SELECT COUNT(*) ... - if (preg_match('/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i', $result->queryString, $m)) { + if (preg_match('/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/ims', $result->queryString, $m)) { $query = $this->dbh->query('SELECT COUNT(*) FROM ' . $m[1], PDO::FETCH_NUM); return $query ? intval($query->fetchColumn(0)) : false; } -- cgit v1.2.3