From: Date: February 23 2006 9:11pm Subject: Connector/NET commit: r203 - in branches/1.0: TestSuite mysqlclient/common List-Archive: http://lists.mysql.com/commits/3081 X-Bug: 16659 Message-Id: <200602232011.k1NKBObF017661@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/1.0/TestSuite/ConnectionTests.cs branches/1.0/mysqlclient/common/DBConnectionString.cs Log: Bug #16659 Can't use double quotation marks(") as password access server by Connector/NET Applied user given patch to trim only quotes that are the first and last character. This allows using quotes as the password (or any connection string value) Modified: branches/1.0/TestSuite/ConnectionTests.cs =================================================================== --- branches/1.0/TestSuite/ConnectionTests.cs 2005-11-18 21:07:55 UTC (rev 202) +++ branches/1.0/TestSuite/ConnectionTests.cs 2006-02-23 20:11:23 UTC (rev 203) @@ -322,5 +322,26 @@ Assert.IsFalse(conn2.Ping()); Assert.IsTrue(conn2.State == ConnectionState.Closed); } + + /// + /// Bug #16659 Can't use double quotation marks(") as password access server by Connector/NET + /// + [Test] + public void ConnectWithQuotePassword() + { + execSQL("GRANT ALL ON *.* to 'test'@'localhost' IDENTIFIED BY '\"'"); + string host = ConfigurationSettings.AppSettings["host"]; + MySqlConnection c = new MySqlConnection("server=" + host + ";uid=test;pwd='\"';pooling=false"); + try + { + c.Open(); + c.Close(); + } + catch (Exception ex) + { + Assert.Fail(ex.Message); + } + execSQL("DELETE FROM mysql.user WHERE user='test'"); + } } } Modified: branches/1.0/mysqlclient/common/DBConnectionString.cs =================================================================== --- branches/1.0/mysqlclient/common/DBConnectionString.cs 2005-11-18 21:07:55 UTC (rev 202) +++ branches/1.0/mysqlclient/common/DBConnectionString.cs 2006-02-23 20:11:23 UTC (rev 203) @@ -196,8 +196,19 @@ parts[1] = parts[1].Trim(); // we also want to clear off any quotes + if (parts[1].Length >= 2) + { + if ((parts[1][0] == '"' && parts[1][parts[1].Length - 1] == '"') || + (parts[1][0] == '\'' && parts[1][parts[1].Length - 1] == '\'')) + { + parts[1] = parts[1].Substring(1, parts[1].Length - 2); + } + } + else + { + parts[1] = parts[1]; + } parts[0] = parts[0].Trim('\'', '"'); - parts[1] = parts[1].Trim('\'', '"'); hash[parts[0]] = parts[1]; }