I am not 100% but I think that you can't use a # in the password field in
includes/conf.php
$db_url = "mysql://drupal:pas#word@localhost/drupal";

When I deliberate give a incorrect password I get:
Warning: MySQL Connection Failed: Access denied for user:

When I put a # in the password in
Warning: MySQL Connection Failed: Can't connect to MySQL server

I think it has to do that # means begin comment in php4.

Comments

gábor hojtsy’s picture

It is not that # is 'begin comment', but that # is 'begin fragment identifier', since this stuff is an URI actually. %23 is the correct escaping of # in a URI, but then Drupal will not understand your %23 as #, since parse_url() used by the MySQL database code does not translate that... So either urldecode() should be applied on the parts resulting from parse_url(), or Drupal will not support / and # and other special chars in DB passwords.

BTW the PEAR DB layer decodes URL special chars when parsing the DSN (the database connection URI), so it might be an example for correcting Drupal. See http://cvs.php.net/co.php/pear/DB/DB.php (the parseDSN method).

Anonymous’s picture

I can live with # not being supported, but a comment in the conf.php
file would be nice. I can imagine other people being bitten by this one.

Maybe parse_url should be named parse_simplified_url :-)

Or create parse_uri with correctly parses uri's.

This also smells like a potential security problem.

Kjartan’s picture

Which PHP version are you using?

[kjartan@hydra modules]$ php -r "var_dump(parse_url('mysql://drupal:pas#word@localhost/drupal'));"
array (
  'scheme' => 'mysql',
  'host' => 'localhost',
  'user' => 'drupal',
  'pass' => 'pas#word',
  'path' => '/drupal',
);

Seems to parse just fine. Drupal simply passes the 'pass' var to mysql_connect() so then it would have to be a bug in PHP somehow.

Anonymous’s picture

php4 -v
4.1.2

So a php version specific related bug then.

moshe weitzman’s picture