Fix tables listing routine when DSN contained a database with unsupported suffix (#7034)

pull/5989/merge
Aleksander Machniak 5 years ago
parent 2e26aee2b6
commit 67898b23e4

@ -10,6 +10,7 @@ CHANGELOG Roundcube Webmail
- Fix so 401 error is returned only on failed logon requests (#7010) - Fix so 401 error is returned only on failed logon requests (#7010)
- Fix db_prefix handling in queries with `TRUNCATE TABLE <name>` and `UNIQUE <name>` (#7013) - Fix db_prefix handling in queries with `TRUNCATE TABLE <name>` and `UNIQUE <name>` (#7013)
- Fix so update.sh script warns about changed defaults (#7011) - 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 RELEASE 1.4.0
------------- -------------

@ -1184,7 +1184,6 @@ class rcube_db
} }
// Find protocol and hostspec // Find protocol and hostspec
// $dsn => proto(proto_opts)/database // $dsn => proto(proto_opts)/database
if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) { if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) {
$proto = $match[1]; $proto = $match[1];
@ -1200,9 +1199,9 @@ class rcube_db
&& strpos($dsn, '/', 2) !== false && strpos($dsn, '/', 2) !== false
&& $parsed['phptype'] == 'oci8' && $parsed['phptype'] == 'oci8'
) { ) {
//oracle's "Easy Connect" syntax: // Oracle's "Easy Connect" syntax:
//"username/password@[//]host[:port][/service_name]" // "username/password@[//]host[:port][/service_name]"
//e.g. "scott/tiger@//mymachine:1521/oracle" // e.g. "scott/tiger@//mymachine:1521/oracle"
$proto_opts = $dsn; $proto_opts = $dsn;
$pos = strrpos($proto_opts, '/'); $pos = strrpos($proto_opts, '/');
$dsn = substr($proto_opts, $pos + 1); $dsn = substr($proto_opts, $pos + 1);
@ -1230,17 +1229,18 @@ class rcube_db
$parsed['socket'] = $proto_opts; $parsed['socket'] = $proto_opts;
} }
// Get dabase if any // Get database if any
// $dsn => database // $dsn => database
if ($dsn) { if ($dsn) {
// /database // /database
if (($pos = strpos($dsn, '?')) === false) { if (($pos = strpos($dsn, '?')) === false) {
$parsed['database'] = rawurldecode($dsn); $parsed['database'] = rawurldecode($dsn);
// /database?param1=value1&param2=value2
} }
else { else {
// /database?param1=value1&param2=value2
$parsed['database'] = rawurldecode(substr($dsn, 0, $pos)); $parsed['database'] = rawurldecode(substr($dsn, 0, $pos));
$dsn = substr($dsn, $pos + 1); $dsn = substr($dsn, $pos + 1);
if (strpos($dsn, '&') !== false) { if (strpos($dsn, '&') !== false) {
$opts = explode('&', $dsn); $opts = explode('&', $dsn);
} }
@ -1255,6 +1255,9 @@ class rcube_db
} }
} }
} }
// remove problematic suffix (#7034)
$parsed['database'] = preg_replace('/;.*$/', '', $parsed['database']);
} }
return $parsed; return $parsed;

Loading…
Cancel
Save