Ticket #893 (closed defect: fixed)

Opened 16 months ago

Last modified 16 months ago

Escaped DSN parts won't be decoded

Reported by: crem0r Owned by: somebody
Priority: critical Milestone: 0.10.4
Component: Other Version: 2.0-DEV
Severity: Keywords: DSN hex encodings decode encode escape
Cc: Has Test:
Status: Has Patch:

Description

I escape my database username 'cr/emer' via the php function urlencode to 'cr%2Femer' as mentioned in the dokumentation:

If your database, option values, username or password contain characters used to delineate DSN parts, you can escape them via URI hex encodings:

If I try to connect I get the following Errormessage:

SQLSTATE[28000] [1045] Access denied for user 'cr%2Femer'@'localhost' (using password: YES)

So it seems that the escaped DSN parts are not decoded to plaintext.

EXAMPLE:

$dsn =         $params->type
     . '://' . urlencode('cr/emer')
     . ':'   . urlencode('p@ssword')
     . '@'   . $params->host
     . '/'   . urlencode($params->dbname)
     . '?'   . urlencode($options);

Doctrine_Manager::getInstance()->openConnection($dsn);

Ouput: SQLSTATE[28000] [1045] Access denied for user 'cr%2Femer'@'localhost' (using password: YES)

So the escaped/encoded DSN-Parts are not decoded.

PATCH: Add the following after line 278 in class Doctrine_Manager:

$adapter['user']  = urldecode($adapter['user']);
$adapter['pass']  = urldecode($adapter['pass']);
$adapter['query'] = urldecode($adapter['query']);

This will decode the escaped/encoded DSN-Parts before they will passed into the new Connection (Line 317: $conn = new $className($this, $adapter);)

Change History

Changed 16 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

(In [4060]) fixes #893

Note: See TracTickets for help on using tickets.