diff options
| author | Mark Newnham <mark@newnhams.com> | 2020-12-10 19:54:42 -0700 |
|---|---|---|
| committer | Mark Newnham <mark@newnhams.com> | 2020-12-10 19:54:42 -0700 |
| commit | 90bc1a6794ece2b02c2a5d238159ae85da3cbd6d (patch) | |
| tree | fe712fe2319fb04da9f69534f75daca7dbc4ab72 | |
| parent | 37ebcc7dfaa8718ea2fa33955a040261a27e2889 (diff) | |
| download | adodb-90bc1a6794ece2b02c2a5d238159ae85da3cbd6d.tar.gz adodb-90bc1a6794ece2b02c2a5d238159ae85da3cbd6d.tar.bz2 adodb-90bc1a6794ece2b02c2a5d238159ae85da3cbd6d.zip | |
DSN database connection with password containing # fails see #651
The # symbol disupts the parse_url function so the password is temorarily substituted during the url decoding phase
| -rw-r--r-- | adodb.inc.php | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/adodb.inc.php b/adodb.inc.php index 4ae8cad7..a3764d73 100644 --- a/adodb.inc.php +++ b/adodb.inc.php @@ -5084,6 +5084,13 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1 if (!defined('ADODB_ASSOC_CASE')) { define('ADODB_ASSOC_CASE', ADODB_ASSOC_CASE_NATIVE); } + + /* + * Are there special characters in the dsn password + * that disrupt parse_url + */ + $needsSpecialCharacterHandling = false; + $errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false; if (($at = strpos($db,'://')) !== FALSE) { $origdsn = $db; @@ -5105,9 +5112,26 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1 $path = substr($path,0,$qmark); } $dsna['path'] = '/' . urlencode($path); - } else + } else { + /* + * Stop # character breaking parse_url + */ + $cFakedsn = str_replace('#','\035',$fakedsn); + if (strcmp($fakedsn,$cFakedsn) != 0) + { + /* + * There is a # in the string + */ + $needsSpecialCharacterHandling = true; + + /* + * This allows us to successfully parse the url + */ + $fakedsn = $cFakedsn; + + } $dsna = @parse_url($fakedsn); - + } if (!$dsna) { return false; } @@ -5138,6 +5162,14 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1 $dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : ''; $dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'],1)) : ''; # strip off initial / + if ($needsSpecialCharacterHandling) + { + /* + * Revert back to the original string + */ + $dsna = str_replace('\035','#',$dsna); + } + if (isset($dsna['query'])) { $opt1 = explode('&',$dsna['query']); foreach($opt1 as $k => $v) { |
