DOMjudge / domjudge

DOMjudge programming contest jury system
https://www.domjudge.org
GNU General Public License v2.0
731 stars 255 forks source link

Error when using password containing question mark #2651

Open eldering opened 2 months ago

eldering commented 2 months ago

On current main branch (and also on 8.2 branch) when I try to use a DB password containing a ?, then during the installation process I get this error:

make[1]: Entering directory '/home/jaap/domjudge/git/domjudge/webapp'
composer auto-scripts
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!  
!!   // Clearing the cache for the dev environment with debug true                  
!!  
!!  
!!  In ConnectionFactory.php line 262:
!!                                
!!    Malformed parameter "url".  
!!                                
!!  
!!  In MalformedDsnException.php line 12:
!!                                       
!!    Malformed database connection URL  
!!                                       
!!  
!!  cache:clear [--no-warmup] [--no-optional-warmers]
!!  
!!  
make[1]: *** [Makefile:72: composer-autoclean] Error 1
make[1]: Leaving directory '/home/jaap/domjudge/git/domjudge/webapp'
make: *** [/home/jaap/domjudge/git/domjudge/Makefile.global:81: inplace-install] Error 1

and I see these errors in the symfony logs:

[2024-08-17T09:05:38.278222+00:00] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\MalformedDsnException: "Malformed parameter "url"." at ConnectionFactory.php line 262 {"exception":"[object] (Doctrine\\DBAL\\Exception\\MalformedDsnException(code: 0): Malformed parameter \"url\". at /home/jaap/domjudge/git/domjudge/webapp/vendor/doctrine/doctrine-bundle/src/ConnectionFactory.php:262)\n[previous exception] [object] (Doctrine\\DBAL\\Exception\\MalformedDsnException(code: 0): Malformed database connection URL at /home/jaap/domjudge/git/domjudge/webapp/vendor/doctrine/dbal/src/Exception/MalformedDsnException.php:12)\n[previous exception] [object] (PDOException(code: 1045): SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO) at /home/jaap/domjudge/git/domjudge/webapp/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php:426)"} []
[2024-08-17T09:05:38.393693+00:00] request.CRITICAL: Exception thrown when handling an exception (Doctrine\DBAL\Exception\MalformedDsnException: Malformed parameter "url". at ConnectionFactory.php line 262) {"exception":"[object] (Doctrine\\DBAL\\Exception\\MalformedDsnException(code: 0): Malformed parameter \"url\". at /home/jaap/domjudge/git/domjudge/webapp/vendor/doctrine/doctrine-bundle/src/ConnectionFactory.php:262)\n[previous exception] [object] (Doctrine\\DBAL\\Exception\\MalformedDsnException(code: 0): Malformed database connection URL at /home/jaap/domjudge/git/domjudge/webapp/vendor/doctrine/dbal/src/Exception/MalformedDsnException.php:12)"} []
[2024-08-17T09:05:38.393797+00:00] php.CRITICAL: Uncaught Exception: Malformed parameter "url". {"exception":"[object] (Doctrine\\DBAL\\Exception\\MalformedDsnException(code: 0): Malformed parameter \"url\". at /home/jaap/domjudge/git/domjudge/webapp/vendor/doctrine/doctrine-bundle/src/ConnectionFactory.php:262)\n[previous exception] [object] (Doctrine\\DBAL\\Exception\\MalformedDsnException(code: 0): Malformed database connection URL at /home/jaap/domjudge/git/domjudge/webapp/vendor/doctrine/dbal/src/Exception/MalformedDsnException.php:12)\n[previous exception] [object] (Doctrine\\DBAL\\Exception\\MalformedDsnException(code: 0): Malformed parameter \"url\". at /home/jaap/domjudge/git/domjudge/webapp/vendor/doctrine/doctrine-bundle/src/ConnectionFactory.php:262)\n[previous exception] [object] (Doctrine\\DBAL\\Exception\\MalformedDsnException(code: 0): Malformed database connection URL at /home/jaap/domjudge/git/domjudge/webapp/vendor/doctrine/dbal/src/Exception/MalformedDsnException.php:12)\n[previous exception] [object] (PDOException(code: 1045): SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO) at /home/jaap/domjudge/git/domjudge/webapp/vendor/symfony/http-foundation/Session/Storage/Handler/PdoSessionHandler.php:426)"} []

It seems that the password is stored and parsed from a URL and probably does not get URL encoded properly.

vmcj commented 2 months ago

I wonder if this is the same as https://github.com/DOMjudge/domjudge/issues/2502.

eldering commented 2 months ago

I wonder if this is the same as #2502.

Quite likely, yes.

vmcj commented 2 months ago

I suspect the problem is in: webapp/config/load_db_secrets.php