Bug #18066: Data source name (DSN) parsing bug + FIX
| From: | tim-phpbug at bitgems dot com | Date: | Sat, 29 Jun 2002 19:39:48 +0000 |
| Subject: | Bug #18066: Data source name (DSN) parsing bug + FIX | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-7410@lists.php.net to get a copy of this message | ||
From: tim-phpbug@bitgems.com
Operating system: Linux Trustix
PHP version: 4.2.1
PHP Bug Type: PEAR related
Bug description: Data source name (DSN) parsing bug + FIX
I'm using a DSN of the format:
mysql://database:password@localhost:/path/to/port/mysql.sock/squirrel
Which seemed like it should work, but it fails because of the way PEAR
parses the DSN: Instead of looking for the last / to deliniate the
database, it looks for the first. I changed the following lines in DB.php,
in the function parseDSN, at line 502:
...
if (strpos($dsn, '/') !== false) {
// **THM**
$offset = strrpos($dsn,'/') ;
$proto_opts = substr($dsn,0,$offset) ;
$dsn = substr($dsn,$offset+1);
// old: list($proto_opts, $dsn) = explode('/', $dsn, 2);
} else {
...
This fixes the problem and should remain compatible with numeric ports as
well. A quick scan of the web site didn't reveal how to submit patches, so
I hope this is Kosher.
--
Edit bug report at http://bugs.php.net/?id=18066&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18066&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18066&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18066&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18066&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18066&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18066&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18066&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18066&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18066&r=globals