/ Check-in [39b566a2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enhance SQLITE_ALLOW_URI_AUTHORITITY to elide //localhost/ and to deal with dodgy URIs that contain too many "/" characters.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:39b566a2d0916c57f3fac756c6d6af149b44781d
User & Date: drh 2015-03-03 16:58:56
Context
2015-03-03
19:56
Fix compiler warnings when compiling under VxWorks 7. check-in: 55c21521 user: drh tags: trunk
16:58
Enhance SQLITE_ALLOW_URI_AUTHORITITY to elide //localhost/ and to deal with dodgy URIs that contain too many "/" characters. check-in: 39b566a2 user: drh tags: trunk
14:00
Fix over-length source code lines in the main.c source file. check-in: debba6f1 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

  2419   2419       flags |= SQLITE_OPEN_URI;
  2420   2420   
  2421   2421       for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&');
  2422   2422       zFile = sqlite3_malloc(nByte);
  2423   2423       if( !zFile ) return SQLITE_NOMEM;
  2424   2424   
  2425   2425       iIn = 5;
  2426         -#ifndef SQLITE_ALLOW_URI_AUTHORITY
         2426  +#ifdef SQLITE_ALLOW_URI_AUTHORITY
         2427  +    if( strncmp(zUri+5, "///", 3)==0 ){
         2428  +      iIn = 7;
         2429  +      /* The following condition causes URIs with five leading / characters
         2430  +      ** like file://///host/path to be converted into UNCs like //host/path.
         2431  +      ** The correct URI for that UNC has only two or four leading / characters
         2432  +      ** file://host/path or file:////host/path.  But 5 leading slashes is a 
         2433  +      ** common error, we are told, so we handle it as a special case. */
         2434  +      if( strncmp(zUri+7, "///", 3)==0 ){ iIn++; }
         2435  +    }else if( strncmp(zUri+5, "//localhost/", 12)==0 ){
         2436  +      iIn = 16;
         2437  +    }
         2438  +#else
  2427   2439       /* Discard the scheme and authority segments of the URI. */
  2428   2440       if( zUri[5]=='/' && zUri[6]=='/' ){
  2429   2441         iIn = 7;
  2430   2442         while( zUri[iIn] && zUri[iIn]!='/' ) iIn++;
  2431   2443         if( iIn!=7 && (iIn!=16 || memcmp("localhost", &zUri[7], 9)) ){
  2432   2444           *pzErrMsg = sqlite3_mprintf("invalid uri authority: %.*s", 
  2433   2445               iIn-7, &zUri[7]);