[php-src] Issue #8345: ODBC's heuristic for guessing if DSN or connection string could be better

From: Date: Mon, 11 Apr 2022 20:29:03 +0000
Subject: [php-src] Issue #8345: ODBC's heuristic for guessing if DSN or connection string could be better
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240851@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8345 Author: NattyNarwhal ### Description The following code: ```php <?php $conn = odbc_connect("DSN=*LOCAL", null, null); var_dump($conn); ``` Resulted in this output: ``` bool(true) ``` But I expected this output instead: ``` PHP Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in /home/calvin/src/test-heuristic.php on line 3 bool(false) ``` The ODBC drivers use strchr(db/dsn, ";") (well, procedural uses strstr, but same deal) to detect if the string the user passed into the constructor is a connection string or not. However, this isn't accurate for connection strings with a single entity (i.e. a DSN=dsn - seems useless versus just using the DSN name, but valid and still useful if you're i.e. building a connection string programatically). One solution might be to use the ODBC quoting rules like in my PR #8307, but there's valid DSNs that use the characters that Microsoft claims have to require quoting. For example, IBM's Db2 for i driver installs a *LOCAL DSN in odbc.ini, which would make the simple DSN name case invalid for that DSN. Another solution is to just scan for a subset of those characters - = might be enough to add, or instead of ;. ### PHP Version 8.2.0-dev ### Operating System Fedora 35

« previous php.bugs (#240851) next »