Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Another attempt at generalizing the URI parsing so that it works with a wider variety of file URIs and yet remains backwards compatible. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | uri-enhancement |
Files: | files | file ages | folders |
SHA1: |
de05eb75ecfd208846d583c82ec05c5c |
User & Date: | drh 2013-07-24 14:54:35 |
Context
2013-08-07
| ||
18:07 | Merge in the latest changes from trunk. (Closed-Leaf check-in: c78b0d30 user: drh tags: uri-enhancement) | |
2013-07-24
| ||
14:54 | Another attempt at generalizing the URI parsing so that it works with a wider variety of file URIs and yet remains backwards compatible. (check-in: de05eb75 user: drh tags: uri-enhancement) | |
2013-07-20
| ||
00:34 | Add 'queryplantest' target to the MSVC makefile. (check-in: ad0551e0 user: mistachkin tags: trunk) | |
Changes
Changes to src/main.c.
︙ | ︙ | |||
2173 2174 2175 2176 2177 2178 2179 | ** method that there may be extra parameters following the file-name. */ flags |= SQLITE_OPEN_URI; for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&'); zFile = sqlite3_malloc(nByte); if( !zFile ) return SQLITE_NOMEM; | | > > > > > > > > > > > > | < | < < > > > > | < < < | | | 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 | ** method that there may be extra parameters following the file-name. */ flags |= SQLITE_OPEN_URI; for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&'); zFile = sqlite3_malloc(nByte); if( !zFile ) return SQLITE_NOMEM; /* Mappings: ** URI FILENAME ** --------------------------- ---------------------- ** file:abc/xyz abc/xyz ** file:/abc/xyz /abc/xyz ** file://abc/xyz //abc/xyz ** file:///abc/xyz /abc/xyz ** file:////abc/xyz //abc/xyz ** file://///abc/xyz //abc/xyz ** file://localhost/xyz /xyz ** file:///c:/abc/xyz /c:/abc/xyz (winOpen() removes leading /) */ iIn = 5; if( strncmp(zUri+5, "///", 3)==0 ){ iIn = 7; /* The following condition causes URIs with five leading / characters ** like file://///host/path to be converted into UNCs like //host/path. ** The correct URI for that UNC has only two or four leading / characters ** file://host/path or file:////host/path. But 5 leading slashes is a ** common error, we are told, so we handle it as a special case. */ if( strncmp(zUri+7, "///", 3)==0 ){ iIn++; } }else if( strncmp(zUri+5, "//localhost/", 12)==0 ){ iIn = 16; } /* Copy the filename and any query parameters into the zFile buffer. ** Decode %HH escape codes along the way. ** ** Within this loop, variable eState may be set to 0, 1 or 2, depending ** on the parsing context. As follows: |
︙ | ︙ |
Changes to test/e_uri.test.
︙ | ︙ | |||
129 130 131 132 133 134 135 | # "localhost", an error is returned to the caller. # if {$tcl_platform(platform) == "unix"} { set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI] foreach {tn uri error} " 1 {file://localhost[test_pwd /]test.db} {not an error} 2 {file://[test_pwd /]test.db} {not an error} | < < | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | # "localhost", an error is returned to the caller. # if {$tcl_platform(platform) == "unix"} { set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI] foreach {tn uri error} " 1 {file://localhost[test_pwd /]test.db} {not an error} 2 {file://[test_pwd /]test.db} {not an error} " { do_test 2.$tn { set DB [sqlite3_open_v2 $uri $flags ""] set e [sqlite3_errmsg $DB] sqlite3_close $DB set e } $error |
︙ | ︙ |
Changes to test/uri.test.
︙ | ︙ | |||
277 278 279 280 281 282 283 | # Check that only "" and "localhost" are acceptable as authorities. # catch {db close} foreach {tn uri res} { 1 "file://localhost/PWD/test.db" {not an error} 2 "file:///PWD/test.db" {not an error} 3 "file:/PWD/test.db" {not an error} | < < < | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | # Check that only "" and "localhost" are acceptable as authorities. # catch {db close} foreach {tn uri res} { 1 "file://localhost/PWD/test.db" {not an error} 2 "file:///PWD/test.db" {not an error} 3 "file:/PWD/test.db" {not an error} } { if {$tcl_platform(platform)=="windows"} { set uri [string map [list PWD [string range [get_pwd] 3 end]] $uri] } else { set uri [string map [list PWD [string range [get_pwd] 1 end]] $uri] } |
︙ | ︙ |