From 594a12b61e93f29c684e93e45edd270d264210fa Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 15 Nov 2019 09:57:14 +0100 Subject: [PATCH] Fix tables listing routine when DSN contained a database with unsupported suffix (#7034) --- CHANGELOG | 1 + program/lib/Roundcube/rcube_db.php | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8b4541aac..bda740c7f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ CHANGELOG Roundcube Webmail - Fix so 401 error is returned only on failed logon requests (#7010) - Fix db_prefix handling in queries with `TRUNCATE TABLE ` and `UNIQUE ` (#7013) - Fix so update.sh script warns about changed defaults (#7011) +- Fix tables listing routine when DSN contained a database with unsupported suffix (#7034) RELEASE 1.4.0 ------------- diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php index c1ad7e105..364df0c9a 100644 --- a/program/lib/Roundcube/rcube_db.php +++ b/program/lib/Roundcube/rcube_db.php @@ -1184,7 +1184,6 @@ class rcube_db } // Find protocol and hostspec - // $dsn => proto(proto_opts)/database if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) { $proto = $match[1]; @@ -1200,9 +1199,9 @@ class rcube_db && strpos($dsn, '/', 2) !== false && $parsed['phptype'] == 'oci8' ) { - //oracle's "Easy Connect" syntax: - //"username/password@[//]host[:port][/service_name]" - //e.g. "scott/tiger@//mymachine:1521/oracle" + // Oracle's "Easy Connect" syntax: + // "username/password@[//]host[:port][/service_name]" + // e.g. "scott/tiger@//mymachine:1521/oracle" $proto_opts = $dsn; $pos = strrpos($proto_opts, '/'); $dsn = substr($proto_opts, $pos + 1); @@ -1230,17 +1229,18 @@ class rcube_db $parsed['socket'] = $proto_opts; } - // Get dabase if any + // Get database if any // $dsn => database if ($dsn) { // /database if (($pos = strpos($dsn, '?')) === false) { $parsed['database'] = rawurldecode($dsn); - // /database?param1=value1¶m2=value2 } else { + // /database?param1=value1¶m2=value2 $parsed['database'] = rawurldecode(substr($dsn, 0, $pos)); $dsn = substr($dsn, $pos + 1); + if (strpos($dsn, '&') !== false) { $opts = explode('&', $dsn); } @@ -1255,6 +1255,9 @@ class rcube_db } } } + + // remove problematic suffix (#7034) + $parsed['database'] = preg_replace('/;.*$/', '', $parsed['database']); } return $parsed;