Ticket #893 (closed defect: fixed)
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);)