vijirams / csharp-sqlite

Automatically exported from code.google.com/p/csharp-sqlite
Other
0 stars 0 forks source link

Wrong parse of connection string. #118

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create directory f.ex on disk "C" with name "===BD===".
2. Try to open db with conenction string 
"Version=3,uri=file:c:\\===BD===\\test.db"

What is the expected output? What do you see instead?
You should open file without problem. But you will get 
InvalidOperationException.

What version of the product are you using? On what operating system?
csharp-sqlite_3_7_5_30.zip

Please provide any additional information below.
In class Community.CsharpSqlite.SQLiteClient.SqliteConnection method 
SetConnectionString:
                                    string[] arg_pieces = piece.Split ('=');
                    if (arg_pieces.Length != 2) {
                        throw new InvalidOperationException ("Invalid connection string");
                    }
                    string token = arg_pieces[0].ToLower (System.Globalization.CultureInfo.InvariantCulture).Trim ();
                    string tvalue = arg_pieces[1].Trim ();
                    string tvalue_lc = arg_pieces[1].ToLower (System.Globalization.CultureInfo.InvariantCulture).Trim ();

Solution can be this code:
            string piece = conn_pieces[i].Trim();
            int firstEqual = piece.IndexOf('=');
            if (firstEqual == -1)
            {
                throw new InvalidOperationException("Invalid connection string");
            }

            string token = piece.Substring(0, firstEqual);
            string tvalue = piece.Remove(0, firstEqual + 1).Trim();
            string tvalue_lc = tvalue.ToLower(System.Globalization.CultureInfo.InvariantCulture).Trim();

It's fix problem with symbol "=". 

Also this code still has bug. Filename can contain "space" at the end and using 
trim we lost it.

Original issue reported on code.google.com by ilya...@gmail.com on 10 Jun 2011 at 10:50

GoogleCodeExporter commented 8 years ago
There is same bug in lates mercurial version 
45741c5db56ea0660b48b15c3901e96bb73424b3 3.7.5

Original comment by ilya...@gmail.com on 10 Jun 2011 at 10:52

GoogleCodeExporter commented 8 years ago
Will implement your patch

Original comment by market.n...@gmail.com on 10 Jun 2011 at 4:18

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 5f548f41fea2.

Original comment by noah.hart@gmail.com on 10 Jun 2011 at 4:19