Skip to content

Instantly share code, notes, and snippets.

@kaworu
Created January 13, 2016 16:31
Show Gist options
  • Save kaworu/e0159353c0ecbc005554 to your computer and use it in GitHub Desktop.
Save kaworu/e0159353c0ecbc005554 to your computer and use it in GitHub Desktop.
diff --git a/no2/sql_query.class.php b/no2/sql_query.class.php
index b2f2442..213f40e 100644
--- a/no2/sql_query.class.php
+++ b/no2/sql_query.class.php
@@ -68,7 +68,7 @@ class No2_SQLQuery
public static function setup($str, $profile = self::DEFAULT_PROFILE)
{
$matches = [];
- if (preg_match('#^mysql://(\w+):(\w+)@(\w+)/(\w+)$#', $str, $matches)) {
+ if (preg_match('#^mysql://(\w+):([^@]+)@([^/]+)/(\w+)$#', $str, $matches)) {
// default MySQL driver using the PDO interface.
$user = $matches[1];
$password = $matches[2];
@@ -77,7 +77,7 @@ class No2_SQLQuery
require_once(NO2DIR . '/pdo_mysql.class.php');
$handle = new No2_PDO_MySQL($hostname, $database, $user, $password);
- } else if (preg_match('#^pgsql://(\w+):(\w+)@(\w+)/(\w+)$#', $str, $matches)) {
+ } else if (preg_match('#^pgsql://(\w+):([^@]+)@([^/]+)/(\w+)$#', $str, $matches)) {
$user = $matches[1];
$password = $matches[2];
$hostname = $matches[3];
@@ -85,7 +85,7 @@ class No2_SQLQuery
require_once(NO2DIR . '/pdo_postgresql.class.php');
$handle = new No2_PDO_PostgreSQL($hostname, $database, $user, $password);
- } else if (preg_match('#^_mysql://(\w+):(\w+)@(\w+)/(\w+)$#', $str, $matches)) {
+ } else if (preg_match('#^_mysql://(\w+):([^@]+)@([^/]+)/(\w+)$#', $str, $matches)) {
// the old mysql interface is still supported, although you must
// "force" it with _mysql as driver.
$user = $matches[1];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment