From 9ac45f5363f581388468673e91890b3c36a072ac Mon Sep 17 00:00:00 2001 From: Justin Brewer Date: Fri, 2 Mar 2012 10:17:13 -0600 Subject: [PATCH] Regex for PDO DSN Old regex matched ADOdb URI. Also, this regex allows the user, pass, host and database information to appear in any order. --- contrib/admin/main.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/admin/main.php b/contrib/admin/main.php index f4a78545..7e746eb3 100644 --- a/contrib/admin/main.php +++ b/contrib/admin/main.php @@ -139,12 +139,12 @@ class AdminPage extends Extension { private function dbdump(Page $page) { $matches = array(); - preg_match("#(\w+)://(\w+):(\w+)@([\w\.\-]+)/([\w_]+)(\?.*)?#", DATABASE_DSN, $matches); - $software = $matches[1]; - $username = $matches[2]; - $password = $matches[3]; - $hostname = $matches[4]; - $database = $matches[5]; + preg_match("#^(?P\w+)\:(?:user=(?P\w+)(?:;|$)|password=(?P\w+)(?:;|$)|host=(?P[\w\.\-]+)(?:;|$)|dbname=(?P[\w_]+)(?:;|$))+#", DATABASE_DSN, $matches); + $software = $matches['proto']; + $username = $matches['user']; + $password = $matches['password']; + $hostname = $matches['host']; + $database = $matches['dbname']; // TODO: Support more than just MySQL.. switch($software) {