RE: [PHP-PEAR] Installing PEAR

From: Date: Thu, 25 Jan 2001 17:49:36 +0000
Subject: RE: [PHP-PEAR] Installing PEAR
References: 1  Groups: php.pear 
Request: Send a blank email to php-pear+get-1167@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, On Thu, 25 Jan 2001, Colin Viebrock wrote: > I've just started switching to PEAR's DB layer and noticed that if > you use something like: > > $db = DB::connect( "mysql://$dbuser:$dbpass@$dbhost/$dbname" ); > > then this will fail when $dbpass contains an "@" character, as it does > in one case for me. I assume it will also fail if there is a ":" or > "@" in the user or pass. > > Is there a way around this? IMHO urlencoding the username and the password would be the right way to specify this, since the connect-string is an URL and conforming to RFC 1738 you have to encode "@" "/" and ":" in the username and password field . It works this way for me using ftp-urls with wget. A little test showed, that PEARs DB.php does not urldecode the username and password. The code in DB.php is (around line 362 in php-4.0.4pl1): if (preg_match('|^([^:]+):([^@]+)@?(.*)$|', $dsn, $arr)) { $parsed['username'] = $arr[1]; $parsed['password'] = $arr[2]; $dsn = $arr[3]; } elseif (preg_match('|^([^:]+)@(.*)$|', $dsn, $arr)) { $parsed['username'] = $arr[1]; $dsn = $arr[2]; } And should read something like: if (preg_match('|^([^:]+):([^@]+)@?(.*)$|', $dsn, $arr)) { $parsed['username'] = urldecode($arr[1]); $parsed['password'] = urldecode($arr[2]); $dsn = $arr[3]; } elseif (preg_match('|^([^:]+)@(.*)$|', $dsn, $arr)) { $parsed['username'] = urldecode($arr[1]); $dsn = $arr[2]; } to perform the encoding metionend above. I am pretty new to PEAR and would like to hear of other more experienced DB.php-User if that would have any implications on DB.php that I missed and if this would be the right way to work around the problem. regards messju mohr -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: public key @ http://lammfellpuschen.de/public.key iD8DBQE6cGc5ubKPpFA4n0URArnrAJ9bZwU/mkDVICFeNrku1qxnFeLQhQCeP2pd gIR4VtSl/3I4v/OZ2b/lGSs= =yYhu -----END PGP SIGNATURE-----

« previous php.pear (#1167) next »