Index: System.Data.SQLite/SQLiteConnection.cs
==================================================================
--- System.Data.SQLite/SQLiteConnection.cs
+++ System.Data.SQLite/SQLiteConnection.cs
@@ -1172,10 +1172,11 @@
if (Convert.ToInt32(FindKey(opts, "Version", DefaultVersion.ToString()), CultureInfo.InvariantCulture) != DefaultVersion)
throw new NotSupportedException(String.Format(CultureInfo.CurrentCulture, "Only SQLite Version {0} is supported at this time", DefaultVersion));
fileName = FindKey(opts, "Data Source", DefaultDataSource);
+ fileName = UnwrapFileName(fileName);
if (String.IsNullOrEmpty(fileName))
{
fileName = FindKey(opts, "Uri", DefaultUri);
if (String.IsNullOrEmpty(fileName))
@@ -1772,10 +1773,45 @@
Marshal.FreeHGlobal(pArg);
}
return rc;
}
+
+ ///
+ /// Removes one set of surrounding single -OR- double quotes from the file
+ /// name and returns the resulting file name. If the string is null, empty,
+ /// or contains quotes that are not balanced, nothing is done and the original
+ /// string will be returned.
+ ///
+ /// The database file name to process.
+ /// The modified database file name.
+ private string UnwrapFileName(string sourceFile)
+ {
+ if (String.IsNullOrEmpty(sourceFile))
+ {
+ //
+ // NOTE: The string is null or empty, return it verbatim.
+ //
+ return sourceFile;
+ }
+
+ int length = sourceFile.Length;
+
+ if (((sourceFile[0] == '\'') && (sourceFile[length - 1] == '\'')) ||
+ ((sourceFile[0] == '"') && (sourceFile[length - 1] == '"')))
+ {
+ //
+ // NOTE: Remove the first and last character.
+ //
+ return sourceFile.Substring(1, length - 2);
+ }
+
+ //
+ // NOTE: No match, return the input string verbatim.
+ //
+ return sourceFile;
+ }
///
/// Expand the filename of the data source, resolving the |DataDirectory|
/// macro as appropriate.
///
ADDED Tests/tkt-8c3bee31c8.eagle
Index: Tests/tkt-8c3bee31c8.eagle
==================================================================
--- /dev/null
+++ Tests/tkt-8c3bee31c8.eagle
@@ -0,0 +1,85 @@
+###############################################################################
+#
+# tkt-8c3bee31c8.eagle --
+#
+# Written by Joe Mistachkin.
+# Released to the public domain, use at your own risk!
+#
+###############################################################################
+
+package require Eagle
+package require Eagle.Library
+package require Eagle.Test
+
+runTestPrologue
+
+###############################################################################
+
+package require System.Data.SQLite.Test
+runSQLiteTestPrologue
+
+###############################################################################
+
+runTest {test tkt-8c3bee31c8-1.1 {built connection string quoting} -setup {
+ unset -nocomplain dataSource o result
+} -body {
+ set o [object create -alias System.Data.SQLite.SQLiteConnectionStringBuilder]
+
+ foreach dataSource [list \
+ "C:\\test_path\\test.db" \
+ "/test_path/test.db" \
+ "C:\\test path\\test.db" \
+ "/test path/test.db" \
+ "C:\\test'path\\test.db" \
+ "/test'path/test.db"] {
+ $o DataSource $dataSource
+ lappend result [list $dataSource [$o ToString]]
+ }
+
+ set result
+} -cleanup {
+ unset -nocomplain dataSource o result
+} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
+System.Data.SQLite} -result {{{C:\test_path\test.db}\
+{data source=C:\test_path\test.db}} {/test_path/test.db\
+{data source=/test_path/test.db}} {{C:\test path\test.db} {data source="C:\test\
+path\test.db"}} {{/test path/test.db} {data source="/test path/test.db"}}\
+{{C:\test'path\test.db} {data source="C:\test'path\test.db"}}\
+{/test'path/test.db {data source="/test'path/test.db"}}}}
+
+###############################################################################
+
+runTest {test tkt-8c3bee31c8-1.2 {open single quoted file name} -setup {
+ unset -nocomplain fileName o
+} -body {
+ set fileName [appendArgs ' [file join [getDatabaseDirectory] \
+ tkt-8c3bee31c8-1.2.db] ']
+
+ set o [object create -alias System.Data.SQLite.SQLiteConnection]
+ $o ConnectionString [appendArgs "Data Source=" $fileName \;]
+ $o Open; # NOTE: This command may throw an exception, failing the test.
+} -cleanup {
+ unset -nocomplain fileName o
+} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
+System.Data.SQLite} -result {}}
+
+###############################################################################
+
+runTest {test tkt-8c3bee31c8-1.3 {open double quoted file name} -setup {
+ unset -nocomplain fileName o
+} -body {
+ set fileName [appendArgs \" [file join [getDatabaseDirectory] \
+ tkt-8c3bee31c8-1.3.db] \"]
+
+ set o [object create -alias System.Data.SQLite.SQLiteConnection]
+ $o ConnectionString [appendArgs "Data Source=" $fileName \;]
+ $o Open; # NOTE: This command may throw an exception, failing the test.
+} -cleanup {
+ unset -nocomplain fileName o
+} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
+System.Data.SQLite} -result {}}
+
+###############################################################################
+
+runSQLiteTestEpilogue
+runTestEpilogue