From 8f25cdc94e107d4472ec266dd0b1aa12d4be0ef0 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 1 Apr 2024 19:06:34 +0200 Subject: [PATCH] SQL/ODBC: don't escape a driver string We must not try to escape a driver string, the user has to make sure that everything is correctly escaped when passing a complete driver string. This fixes a regression from QTBUG-122642. Fixes: QTBUG-123444 Change-Id: I43316c7a09060f5c8117fdc3c464d239e37d9cdf Reviewed-by: Mark Brand (cherry picked from commit 9873f4b283dcabefc20b1720bef1958c2b1ccc02) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/sqldrivers/odbc/qsql_odbc.cpp | 2 +- src/sql/doc/src/sql-driver.qdoc | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp index cde56459c4a..ae13f9eb6a0 100644 --- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp +++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp @@ -1968,7 +1968,7 @@ bool QODBCDriver::open(const QString & db, connQStr = "FILEDSN="_L1 + ensureEscaped(db); else if (db.contains("DRIVER="_L1, Qt::CaseInsensitive) || db.contains("SERVER="_L1, Qt::CaseInsensitive)) - connQStr = ensureEscaped(db); + connQStr = db; else connQStr = "DSN="_L1 + ensureEscaped(db); diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc index 8593233d1b4..4cc5b0d0506 100644 --- a/src/sql/doc/src/sql-driver.qdoc +++ b/src/sql/doc/src/sql-driver.qdoc @@ -404,15 +404,20 @@ of the ODBC driver. ODBC support can be used as a fallback for compliant databases if no native driver is available. - On Windows, an ODBC driver manager should be installed by default. + On Windows, an ODBC driver manager is installed by default. For Unix systems, there are some implementations which must be installed first. Note that every end user of your application is required to have an ODBC driver manager installed, otherwise the QODBC plugin will not work. When connecting to an ODBC datasource, you should pass the name - of the ODBC datasource to the QSqlDatabase::setDatabaseName() + of the ODBC datasource (DSN) to the QSqlDatabase::setDatabaseName() function, rather than the actual database name. + It's also possible to pass a FILEDSN (*.dsn) filename or a complete + ODBC driver string. When passing a driver string you must make sure, + that all parameters (username, password, ...) are properly escaped. + Passing the username or password through the QSqlDatabase functions, + the escaping is done by the QODBC plugin. The QODBC Plugin needs an ODBC compliant driver manager version 2.0 or later. Some ODBC drivers claim to be version-2.0-compliant,